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

Neither Labels nor Annotations are currently supported for CRDs #45

Closed
fire-ant opened this issue Jun 29, 2022 · 19 comments · Fixed by #47
Closed

Neither Labels nor Annotations are currently supported for CRDs #45

fire-ant opened this issue Jun 29, 2022 · 19 comments · Fixed by #47

Comments

@fire-ant
Copy link
Contributor

until the follow are reviewed and merged can we remove the labels and annotations from the CRD template?

kubernetes-sigs/controller-tools#691
kubernetes-sigs/controller-tools#454

It doesnt make sense to include something which will be rejected at a later point by native tooling. Maybe better to use kustomize and point to how that could work if needed as an option

@fire-ant
Copy link
Contributor Author

#46

@AssafKatz3
Copy link

AssafKatz3 commented Jul 7, 2022

We also need it, we tried to work with Ambassador Edge Stack CRDs but got junk due to this issue

@arttor
Copy link
Owner

arttor commented Jul 7, 2022

@AssafKatz3 @fire-ant please upgrade to release v0.3.15. All CRD labels and annotations are preserved. Standard labels like:

  labels:
    helm.sh/chart: operator-0.1.0
    app.kubernetes.io/name: operator
    app.kubernetes.io/instance: tst
    app.kubernetes.io/version: "0.1.0"
    app.kubernetes.io/managed-by: Helm

will be generated by Helm.

Thank you for reporting the issue!

@AssafKatz3
Copy link

@AssafKatz3 @fire-ant please upgrade to release v0.3.15. All CRD labels and annotations are preserved. Standard labels like:

  labels:
    helm.sh/chart: operator-0.1.0
    app.kubernetes.io/name: operator
    app.kubernetes.io/instance: tst
    app.kubernetes.io/version: "0.1.0"
    app.kubernetes.io/managed-by: Helm

will be generated by Helm.

Thank you for reporting the issue!

Hi,
@arttor I upgraded to release v0.3.16 but I still got:
{{- include "aes-crds.labels" . | nindent 4 }}
In consulresolver-crd.yaml after applying it to Ambassador Edge Stack CRDs. And this is an error since CRDs are not templated.
Thanks

@arttor
Copy link
Owner

arttor commented Jul 10, 2022

Ok, now i am not sure that it is a good idea to use -cdr-dir. Because it will never work for webhook certificate annotation. I think that we should remove this option.

@AssafKatz3
Copy link

@arttor
This is a good option, but it should simply omit the files without any modification in text.
Thanks

@AssafKatz3
Copy link

Currently I must use:

helmify -crd-dir -v "${chart_path}" < "$filename"
kubectl-slice --skip-non-k8s --input-file "$filename" --output-dir "${chart_path}/crds" --include-kind CustomResourceDefinition --template '{{.spec.names.singular}}-crd.yaml'

But there is no reason why need two tools for it.

@arttor
Copy link
Owner

arttor commented Jul 10, 2022

Please don't use -crd-dir option. Since crds does not support templating it won't work for operators using validation webhooks.

@AssafKatz3
Copy link

@arttor It still breaks the CRD into another directory so it still useful for it.

@arttor
Copy link
Owner

arttor commented Jul 10, 2022

I can disable crd templating for -crd-dir to make it work just for your project. But I am afraid that if I do so I we will have another issue: annotation cert-manager.io/inject-ca-from is incorrectly resolved.

So we will always have situation when option -crd-dir not fully supports all project features.

What are benefits of having CRDs in a separate directory?

@AssafKatz3
Copy link

make it work just for your project. But I am afraid that if I do so I we will have another issue: annotation cert-manager.io/inject-ca-from is incorrectly resolved.

Hi,
cert-manager.io/inject-ca-from annotation doesn't make sense for CRDs, so we don't need it.

HELM 3 requires the CRDs to be in crds directory, so splitting them is required.
Thanks

@arttor
Copy link
Owner

arttor commented Jul 10, 2022

For kubebuilder/operator-sdk projecs kustomize config or helm chart does not contain CRD instances. You install operator with one chart and the create CRD instances with a separate one.

@AssafKatz3
Copy link

For kubebuilder/operator-sdk projecs kustomize config or helm chart does not contain CRD instances. You install operator with one chart and the create CRD instances with a separate one.

Hi,
There are projects without such clear cut (using method 1 per HELM documentation). I am using this tool for one of them Ambassador Edge Stack CRDs.
Thanks

@arttor
Copy link
Owner

arttor commented Jul 10, 2022

I fully understand that cert-manager is not relevant for you project. But is required for most of operators which is also using this tool.
I fully agree that current implementations of -crd-dir not makes only sense because it adds templates.
I need to think about on how to warn users to not use this option for kubebuilder projects

@AssafKatz3
Copy link

AssafKatz3 commented Jul 10, 2022

I fully understand that cert-manager is not relevant for you project. But is required for most of operators which is also using this tool. I fully agree that current implementations of -crd-dir not makes only sense because it adds templates. I need to think about on how to warn users to not use this option for kubebuilder projects

Hi,
The point wasn't that cert-manager isn't relevant to CRDs, any CRD, cert-manager won't do anything due to this adding, so you don't need to add it to CRDs, even if your project uses it.
Thanks

@arttor
Copy link
Owner

arttor commented Jul 10, 2022

@arttor
Copy link
Owner

arttor commented Jul 10, 2022

But anyway i will remove CRD templating from -crd-dir option

@arttor
Copy link
Owner

arttor commented Jul 10, 2022

@AssafKatz3 disabled CRD templating for -crd-dir in v0.3.17.

@fire-ant
Copy link
Contributor Author

Hi, The point wasn't that cert-manager isn't relevant to CRDs, any CRD, cert-manager won't do anything due to this adding, so you don't need to add it to CRDs, even if your project uses it. Thanks

@arttor thanks for the. fix. I think to satisfy both use cases it might be useful to list out a set of labels which are applied to everything but crd's and filter these out at the point of rendering. we can have our cake and eat it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants