-
Notifications
You must be signed in to change notification settings - Fork 468
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
Properly handle different versioned resources in gwctl (eg. v1beta1 v/s v1 APIs) and related code cleanups #3001
Properly handle different versioned resources in gwctl (eg. v1beta1 v/s v1 APIs) and related code cleanups #3001
Conversation
/cc @mlavacca |
3c51c51
to
6cf42ae
Compare
c172d6d
to
a9369f8
Compare
The dynamic client returned for unit tests may not be smart enough to automatically guess the APIVersion and Kind (which the real kube-apiserver can handle automatically). To get over this, we can simply simply include these when creating the objects.
3f7ef46
to
6c18bf8
Compare
/retest |
… API types. Clusters may not always have the v1 CRDs installed. This means gwctl will have to use whatever version is available in the cluster. Hence, we will use API Discovery to determine the "preferred" API version as per the kube-apiserver and then use a dynamic client to fetch that specific versioned resource. Once that specific versioned resource is fetched (e.g. v1beta1.Gateway), it will be converted to a concrete type used within gwctl (eg. v1.Gateway), which will usually be a more newer/stable version. For most cases, this conversion should not result in any losses. If in the future, a need arises for such special cases, we should be able to extend the approach by configuring some conversion functions (eg. conversion function for v1beta1.Gateway -> v1.Gateway).
6c18bf8
to
9d9aa93
Compare
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.
Thanks @gauravkghildiyal, this looks like a great addition!
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: gauravkghildiyal, robscott The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
…Gateway API types.
/lgtm |
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
Use API discovery to determine the preferred API versions for Gateway API types.
Clusters may not always have the v1 CRDs installed. This means gwctl will have
to use whatever version is available in the cluster. Hence, we will use API
Discovery to determine the "preferred" API version as per the kube-apiserver and
then use a dynamic client to fetch that specific versioned resource.
Once that specific versioned resource is fetched (e.g. v1beta1.Gateway), it will
be converted to a concrete type used within gwctl (eg. v1.Gateway), which will
usually be a more newer/stable version. For most cases, this conversion should
not result in any losses. If in the future, a need arises for such special
cases, we should be able to extend the approach by configuring some conversion
functions (eg. conversion function for v1beta1.Gateway -> v1.Gateway).
Which issue(s) this PR fixes:
Fixes #3000
Does this PR introduce a user-facing change?:
/area gwctl