feat(api): add Kubernetes client-go style typed clients for Envoy Gateway resources#7356
Conversation
Signed-off-by: siddharth1036 <siddharth.shah@nutanix.com>
| cd .. | ||
|
|
||
| - name: Verify generated code | ||
| run: make kube-verify-clients |
There was a problem hiding this comment.
instead if a new action, can we reuse make geo-check thats part of CI already ?
tools/src/update-codegen.sh
Outdated
| set -o nounset | ||
| set -o pipefail | ||
|
|
||
| SCRIPT_ROOT=$(dirname "${BASH_SOURCE[0]}")/../.. |
There was a problem hiding this comment.
can this be represented in the make target similar to what was being done in the previous PR
Signed-off-by: siddharth1036 <siddharth.shah@nutanix.com>
Signed-off-by: siddharth1036 <siddharth.shah@nutanix.com>
Signed-off-by: siddharth1036 <siddharth.shah@nutanix.com>
api/v1alpha1/groupversion_info.go
Outdated
| &ClientTrafficPolicyList{}, | ||
| &EnvoyExtensionPolicy{}, | ||
| &EnvoyExtensionPolicyList{}, | ||
| &EnvoyGateway{}, |
There was a problem hiding this comment.
this seems not right, EnvoyGateway is not a CRD.
There was a problem hiding this comment.
Sure, let me check on this
There was a problem hiding this comment.
Hi @zirain I checked on this, it seems like the type is required to decode EnvoyGateway resource here:
I tried to check a way around this but didn't find a cleaner way to do this, can you suggest if something can be worked out for the same?
There was a problem hiding this comment.
it's stored in configmap, it won't be submitted to apiserver.
it's meaningless to add it to scheme.
There was a problem hiding this comment.
Hi @zirain ! I've investigated a few different approaches to address your concern about EnvoyGateway not being a CRD.
I've implemented a solution that uses a separate decoder scheme specifically for configuration decoding. This way, the decoder scheme can include the EnvoyGateway type for YAML deserialization purposes, while the main runtime scheme (used for CRDs) remains clean and only contains actual Kubernetes API resources.
When you have a moment, would you mind reviewing the changes in commit here ? I'd really appreciate your feedback on whether this approach addresses your concerns or if you'd like me to explore a different solution.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7356 +/- ##
==========================================
+ Coverage 72.29% 72.32% +0.03%
==========================================
Files 231 232 +1
Lines 34084 34103 +19
==========================================
+ Hits 24641 24666 +25
+ Misses 7670 7666 -4
+ Partials 1773 1771 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: siddharth1036 <siddharth.shah@nutanix.com>
Signed-off-by: siddharth1036 <siddharth.shah@nutanix.com>
Signed-off-by: siddharth1036 <siddharth.shah@nutanix.com>
…re/gateway-client-packages Signed-off-by: siddharth1036 <siddharth.shah@nutanix.com>
Signed-off-by: siddharth1036 <siddharth.shah@nutanix.com>
test/e2e/tests/response-override.go
Outdated
| ) { | ||
| if timeoutConfig == nil { | ||
| t.Fatalf("timeoutConfig cannot be nil") | ||
| return |
There was a problem hiding this comment.
why we need this? can we split these changes into a separated PR to keep this one as clean as possible?
There was a problem hiding this comment.
Actually the lint was failing for me locally therefore made the change, let me revert and check if CI fails
Signed-off-by: siddharth1036 <siddharth.shah@nutanix.com>
|
/retest |
Signed-off-by: siddharth1036 <siddharth.shah@nutanix.com>
tools/make/kube.mk
Outdated
| # Note that the paths can't just be "./..." with the header file, or the tool will panic on run. Sorry. | ||
| @$(LOG_TARGET) | ||
| $(GO_TOOL) controller-gen $(CONTROLLERGEN_OBJECT_FLAGS) paths="{$(ROOT_DIR)/api/...,$(ROOT_DIR)/internal/ir/...,$(ROOT_DIR)/internal/gatewayapi/...}" | ||
| $(GO_TOOL) controller-gen $(CONTROLLERGEN_OBJECT_FLAGS) paths="{$(ROOT_DIR)/api/...,$(ROOT_DIR)/internal/gatewayapi/...}" |
There was a problem hiding this comment.
why was $(ROOT_DIR)/internal/ir/ deleted, we need IR DeepCopy / used by watchable
…re/gateway-client-packages Signed-off-by: siddharth1036 <siddharth.shah@nutanix.com>
Signed-off-by: siddharth1036 <siddharth.shah@nutanix.com>
…ddharth1036/envoy-gateway into feature/gateway-client-packages
What type of PR is this?
feat(api): add Kubernetes client-go style typed clients for Envoy Gateway resources
What this PR does / why we need it:
This PR adds Kubernetes-style typed clientsets, informers, and listers for Envoy Gateway's custom resources, enabling external users to programmatically interact with Envoy Gateway resources using familiar patterns from
kubernetes/client-go.Key Changes:
1. Client Generation Infrastructure
client-gen,lister-gen, andinformer-genfromk8s.io/code-generatorto toolstools/src/update-codegen.shscript to generate typed clientstools/src/verify-codegen.shscript to verify generated code is up-to-datemake kube-generate-clientsandmake kube-verify-clients2. API Annotations
Added code-generator annotations to 8 CRD types in
api/v1alpha1/:BackendandBackendListBackendTrafficPolicyandBackendTrafficPolicyListClientTrafficPolicyandClientTrafficPolicyListEnvoyExtensionPolicyandEnvoyExtensionPolicyListEnvoyPatchPolicyandEnvoyPatchPolicyListEnvoyProxyandEnvoyProxyListHTTPRouteFilterandHTTPRouteFilterListSecurityPolicyandSecurityPolicyListAnnotations added:
+genclient- Marks types for client generation+k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object- Ensures runtime.Object interface compliance+k8s:deepcopy-gen=package- Enables package-level deepcopy generation indoc.go3. Scheme Registration Updates
Updated
api/v1alpha1/groupversion_info.go:SchemeBuilderto useruntime.NewSchemeBuilderfor code-generator compatibilitylocalSchemeBuilderfor controller-runtime compatibilitySchemeGroupVersionalias for generated client compatibilityaddKnownTypesto register all 8 CRD types and their list types4. Generated Client Code (49 files)
Clientsets (
pkg/client/clientset/versioned/):Informers (
pkg/client/informers/externalversions/):Listers (
pkg/client/listers/api/v1alpha1/):5. Testing
Added
pkg/client/clientset_test.go:6. CI/CD Integration
.github/workflows/verify-codegen.yamlworkflow to enforce generated code is up-to-date.github/codecov.ymlto exclude generated client code from coverage reportsgen-checkworkflowBenefits:
Example Usage:
Design Decisions:
This approach follows
kubernetes/sample-controllerand matches what other projects like cert-manager and external-dns use.Which issue(s) this PR fixes:
Fixes #
Release Notes: Yes
Checklist:
+genclienttagsupdate-codegen.sh,verify-codegen.sh)kube-generate-clients,kube-verify-clients)pkg/client/clientset_test.go)