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

Incorrect CRD generated after adding webhook/ca injection patches to kustomize #1633

Closed
robherley opened this issue Aug 11, 2020 · 5 comments
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@robherley
Copy link

When adding the patches for webhooks/cert manager, the subresources field for the CRD is empty and missing the status field.

Steps to reproduce:

$ kubebuilder init --domain robherley.xyz --repo github.com/robherley/example 
$ kubebuilder create api --group=example --version=v1alpha1 --kind=Foobar

<added subresource marker to _types file>

$ make manifests

$ kustomize build config/default | grep subresources -C 1
  scope: Namespaced
  subresources:
    status: {}

<uncommented the patches in config/crd/kustomization.yaml>

$ kustomize build config/default | grep subresources -A 1
  scope: Namespaced
  subresources: {}
  validation:
  • go version
    v1.14.5
  • kubebuilder version (kubebuilder version) and scaffolding version (check your PROJECT file)
    kubebuilder: v2.3.1 and scaffolding: v2
  • controller-runtime version (check your go.mod file)
    v0.5.0
  • Kubernetes & kubectl versions (just run kubectl version against your API server)
    client: v1.18.3 and server: v1.17.1

/kind bug

@k8s-ci-robot k8s-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Aug 11, 2020
@camilamacedo86
Copy link
Member

Hi @robherley,

Could you please check it with the master branch and the v3-alpha plugin?

E.g:

kubebuilder init --plugins=go/v3-alpha --domain=tutorial.kubebuilder.io --project-version=3-alpha --repo=tutorial.kubebuilder.io/project --license apache2 --owner "The Kubernetes authors"

Let's see it is not solved with the latest version and plugin. Also, if not could you please clarify what is the value scaffolded as you did and what is the value expected by you?

@robherley
Copy link
Author

robherley commented Aug 16, 2020

Here's the steps I followed for the master branch (3c4eb4f):

$ kubebuilder init --plugins=go/v3-alpha --domain=tutorial.kubebuilder.io --project-version=3-alpha --repo=tutorial.kubebuilder.io/project --license apache2 --owner "The Kubernetes authors"

$ kubebuilder create api --group=example --version=v1alpha1 --kind=Foobar

$ make manifests

$ kustomize build config/default > before_patch.yaml

That yaml has the correct spec.subresources.status for the CustomResourceDefinition:

apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
  ...
spec:
  ...
  subresources:
    status: {} # this is correct
...

But if I uncomment the patches for the webhooks in config/crd/kustomization:

patchesStrategicMerge:
  - patches/webhook_in_foobars.yaml
  - patches/cainjection_in_foobars.yaml

And regenerate the manifests:

$ make manifests

$ kustomize build config/default > after_patch.yaml

It's missing the status subresource:

apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
  ...
spec:
  ...
  subresources: {} # missing status
...

I've attached before_patch.yaml and after_patch.yaml: generated.zip

@rajasaur
Copy link

This might be related: #1655

@camilamacedo86
Copy link
Member

camilamacedo86 commented Oct 21, 2020

Hi @robherley,

Are you using the kustomize version defined in the Makefile or other version? If yes, we might be able to close this one with #1735? Could you help on the review of the PR? Also, we have an issue to upgrade the kustomize version and fix its issues see #1657. Would you like to help on it?

@robherley
Copy link
Author

Hi @camilamacedo86, I just ran my tests again with the latest commit on master (36124ae) and used the kustomize version specified in the Makefile (v3.5.4) and it generates the correct output. I'll close this issue and I can take a look at #1657. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

No branches or pull requests

4 participants