-
Notifications
You must be signed in to change notification settings - Fork 584
feat(api): add Kubernetes client-go style typed clients for Envoy Gateway resources #7356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat(api): add Kubernetes client-go style typed clients for Envoy Gateway resources #7356
Conversation
Signed-off-by: siddharth1036 <[email protected]>
| cd .. | ||
| - name: Verify generated code | ||
| run: make kube-verify-clients |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this be represented in the make target similar to what was being done in the previous PR
Signed-off-by: siddharth1036 <[email protected]>
Signed-off-by: siddharth1036 <[email protected]>
Signed-off-by: siddharth1036 <[email protected]>
api/v1alpha1/groupversion_info.go
Outdated
| &ClientTrafficPolicyList{}, | ||
| &EnvoyExtensionPolicy{}, | ||
| &EnvoyExtensionPolicyList{}, | ||
| &EnvoyGateway{}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems not right, EnvoyGateway is not a CRD.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, let me check on this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @zirain I checked on this, it seems like the type is required to decode EnvoyGateway resource here:
| gvk.Kind != egv1a1.KindEnvoyGateway { |
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.38%
=======================================
Files ? 232
Lines ? 34030
Branches ? 0
=======================================
Hits ? 24631
Misses ? 7628
Partials ? 1771 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: siddharth1036 <[email protected]>
Signed-off-by: siddharth1036 <[email protected]>
Signed-off-by: siddharth1036 <[email protected]>
…re/gateway-client-packages Signed-off-by: siddharth1036 <[email protected]>
Signed-off-by: siddharth1036 <[email protected]>
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)