Skip to content
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

Unable to use apiextensions.k8s.io/v1 as CRD version for envtest #1034

Closed
billcchung opened this issue Jul 8, 2020 · 7 comments
Closed

Unable to use apiextensions.k8s.io/v1 as CRD version for envtest #1034

billcchung opened this issue Jul 8, 2020 · 7 comments
Labels
priority/awaiting-more-evidence Lowest priority. Possibly useful, but not yet enough support to actually get it done.
Milestone

Comments

@billcchung
Copy link

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!

@vincepri
Copy link
Member

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

@k8s-ci-robot k8s-ci-robot added this to the Next milestone Jul 22, 2020
@k8s-ci-robot k8s-ci-robot added the priority/awaiting-more-evidence Lowest priority. Possibly useful, but not yet enough support to actually get it done. label Jul 22, 2020
@jiachengxu
Copy link
Contributor

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.

@vincepri
Copy link
Member

We could add a check in envtest to validate that the API server is at least v1.16 when using CRDv1

@fejta-bot
Copy link

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

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Nov 16, 2020
@camilamacedo86
Copy link
Member

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Nov 16, 2020
@vincepri
Copy link
Member

Do we have an action item here? I don't know if this is a real controller runtime issue

@billcchung
Copy link
Author

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority/awaiting-more-evidence Lowest priority. Possibly useful, but not yet enough support to actually get it done.
Projects
None yet
Development

No branches or pull requests

6 participants