Hi I'm hitting an issue when trying to update our CRD version to apiextensions.k8s.io/v1
I'm using controller-gen 0.3.0, and added crd:crdVersions=v1 as CRD generation option, it successfully generated as
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.3.0
however envtest seems only initialized v1beta1, I kept getting the following error from suite_test.go:
Unexpected error:
<*meta.NoKindMatchError | 0xc00072db40>: {
GroupKind: {
Group: "apiextensions.k8s.io",
Kind: "CustomResourceDefinition",
},
SearchedVersions: ["v1"],
}
no matches for kind "CustomResourceDefinition" in version "apiextensions.k8s.io/v1"
occurred
pkg versions:
k8s.io/api v0.18.5
k8s.io/apimachinery v0.18.5
k8s.io/client-go v0.18.5
sigs.k8s.io/controller-runtime v0.6.0
I see envtest has https://github.com/kubernetes-sigs/controller-runtime/blob/release-0.6/pkg/envtest/helper.go#L16,
but k8s.io/api doesnt have v1 yet: https://pkg.go.dev/k8s.io/[email protected], is it because of this? is so is there plan to add or any workaround?
Thanks!
CRD v1 are part of apiextensions, not k8s.io/api. You can find them in apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1". You should add the types into your Scheme though, like https://github.com/kubernetes-sigs/controller-runtime/blob/release-0.6/pkg/envtest/helper.go#L16
/priority awaiting-more-evidence
/milestone Next
I had the same issue before, please check the version of your kubebuilder/bin/kube-apiserver binary, because if you are using envtest in your test, it will interact with the kube-apiserver on your machine, if the version is too old, maybe v1 CRD is not served.
We could add a check in envtest to validate that the API server is at least v1.16 when using CRDv1
Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close.
Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale
/remove-lifecycle stale
Do we have an action item here? I don't know if this is a real controller runtime issue
thank you @jiachengxu! Confirmed it works with kubebuilder 2.3.1, which version is v1.16.4, I'll close this issue now, thanks everyone!
Most helpful comment
I had the same issue before, please check the version of your
kubebuilder/bin/kube-apiserverbinary, because if you are usingenvtestin your test, it will interact with the kube-apiserver on your machine, if the version is too old, maybev1CRD is not served.