-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Bump CRD API version to v1 #3614
Conversation
@jenting Considering Velero is used for upgrading from older Kubernetes versions to newer versions we will want to be able to Velero going back to kubernetes 1.12. For that reason, we might want to hold off on this PR. |
Make sense. Also, it seems like we need to update the Velero prerequisite on Kubernetes version, ref to |
Kubernetes v1.22 is where the v1beta1 APIs will be completely removed. I'd like to make progress on this, but I think we'll be looking at leveraging Carvel to do so. We have #2505 to track the work. |
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.
More of a question at this point than a specific request for changes, but should we use v1 as the default rather than v1beta1?
Also, I'd like to have the flexibility to choose a CRD apiversion when running e2e tests. I actually made a local change to add that option in my git checkout so I could test running e2e tests with the new CRDs. It might be easier for me to just submit that as a follow-on PR rather than trying to get that added here. Without that, e2e tests just use the default CRDsVersion from NewInstallOptions()
pkg/cmd/cli/install/install.go
Outdated
@@ -128,6 +133,7 @@ func NewInstallOptions() *InstallOptions { | |||
UseVolumeSnapshots: true, | |||
NoDefaultBackupLocation: false, | |||
CRDsOnly: false, | |||
CRDsVersion: "v1beta1", |
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.
I wonder whether we should default to "v1" instead of "v1beta1" since it's the preferred version for recent kube versions, even before 1.22. This would require users on kube 1.15 and older to override this, rather than requiring users on current kubernetes to override it.
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.
I agree with this. I think if we switch the default now, then we only need to give one notice to users: The default is v1, if you need a previous version, you can override it. Otherwise we would need to instruct Kubernetes 1.22+ users to override now, and then tell both user groups to either add or drop the override once the defaults are switched.
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.
@zubron Does it make sense to ignore e2e tests in this PR (nothing here breaks them), and I'll submit a follow-on PR to add CRDS_VERSION as an option (so you can do CRDS_VERSION=v1beta1 make test-e2e
) I already have the code for it in my local checkout.
Thank you @sseago for quickly go ahead, appreciate. |
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.
There are further changes needed in this PR to ensure that the uninstall behaviour works in 1.22. Currently our uninstall code uses the v1beta1 API to fetch the CRDs to delete: https://github.com/vmware-tanzu/velero/blob/main/pkg/cmd/cli/uninstall/uninstall.go#L127-L154
This will result in an error when running on Kubernetes 1.22:
$ v uninstall --kubecontext kind-1.22
You are about to uninstall Velero.
Are you sure you want to continue (Y/N)? y
Velero namespace "velero" does not exist, skipping.
Velero ClusterRoleBinding "velero" does not exist, skipping.
Errors while attempting to uninstall Velero: "no matches for kind \"CustomResourceDefinition\" in version \"apiextensions.k8s.io/v1beta1\""An error occurred: no matches for kind "CustomResourceDefinition" in version "apiextensions.k8s.io/v1beta1"
I'm not sure of the best way to solve this. I don't know if there is a generic way to get the CRDs regardless of the API version used, or whether we need to attempt to delete both v1beta1 and v1 CRDs (checking for the appropriate errors from the API server).
} | ||
|
||
// Update the group apiextensions.k8s.io preferred API version | ||
o.CRDsVersion = gvr.Version |
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.
With this, the API server preferred version will always take precedence over the setting provided by the user with the --crds-version
flag. Is there a case where the user may want to explicitly use v1beta1 when the preferred version is v1?
Also, in the case where Velero can't find the server preferred version, we should output a warning or log to state that the preferred version couldn't be found and that instead we will use v1
as the default and that it can be changed with the --crds-version
flag. Otherwise, I think we may encounter users who think that the CRD installation is broken on pre-1.16 clusters if the discovery fails.
@jenting After discussing with @dsu-igeek, we decided to go ahead and merge this branch as is and @dsu-igeek will work on fixing the uninstall issue. I am going to rebase this branch on top of main and push it to resolve the merge conflicts. Thank you so much for taking care of this issue! 😄 |
Signed-off-by: JenTing Hsiao <[email protected]>
Signed-off-by: JenTing Hsiao <[email protected]>
If the Velero CLI can't discover the Kubernetes preferred CRD API version, use the flag --crds-version to determine the CRDs version. Signed-off-by: JenTing Hsiao <[email protected]>
Signed-off-by: JenTing Hsiao <[email protected]>
update the path of crds.go to ignore it. Signed-off-by: JenTing Hsiao <[email protected]>
Signed-off-by: JenTing Hsiao <[email protected]>
Signed-off-by: JenTing Hsiao <[email protected]>
Signed-off-by: JenTing Hsiao <[email protected]>
Signed-off-by: JenTing Hsiao <[email protected]>
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.
Thank you again, @jenting!
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.
LGTM
Sorry, I missed the |
Please add a summary of your change
--crds-version
to allow the user to specify which CRDs version to render. If the Kubernetes CRDs preferred API version is discoverable, use the discovered version.Does your change fix a particular issue?
Fixes #2505
Please indicate you've done the following:
/kind changelog-not-required
.site/content/docs/main
.