cert-manager: CRDs shouldn't be templated in Helm...
I’m trying to install CRDs in a more proper way, meaning not using the /crds directory at the top level of Helm, b/c it doesn’t allow for upgrading. If you read, https://helm.sh/docs/chart_best_practices/custom_resource_definitions/#method-1-let-helm-do-it-for-you
I’m running into issue with my automation to install CRDs though b/c they are templated and things in the CRD folder shouldn’t be templated. From the link above.
There is now a special directory called crds that you can create in your chart to hold your CRDs. These CRDs are not templated, but will be installed by default when running a helm install for the chart. If the CRD already exists, it will be skipped with a warning. If you wish to skip the CRD installation step, you can pass the --skip-crds flag.
Further it feels like there really isn’t a needed b/c all it’s setting are labels. I’m more than happy to open a PR for this.
About this issue
- Original URL
- State: open
- Created a year ago
- Reactions: 6
- Comments: 28 (4 by maintainers)
Thank you everyone for all the input here!
I have a desire to have the CRDs in their own chart (option 4). Given that this topic is about whether to template or not to template those CRDs… perhaps we could:
/crdsdirectory)If we had both of those additional charts… people could pick their poison? Naming is up for debate but illustrates a possible route forward.
Apparently, the
kube-prometheus-stackHelm chart, where I saw the option 3 pattern, moved to the option 4 😅Here is the issue where they had the same discussion and a comment about automation for the CRD dedicated chat:
https://github.com/prometheus-community/helm-charts/issues/2612
My apologies for not making that clear in the list - I ran with the assumption that any templating would be removed in all scenarios. I agree with you that it’s an additional lifecycle concern that no one should have to deal with, and the other projects I’ve seen that use Helm to deploy CRDs are only applying a static dump. Thank you for bringing up that detail.
Presented options:
crds/I really think option 4 is the best, given all the scenarios and concerns.
note: my deleted reply was to a mistaken interpretation. I hope this list helps create a more clear shared understanding. my apologies for coming in hot 😄
I did some tests with the FluxCD Kustomization controller and find somehow a “”“solution”“” to use the healthcheck feature. I simply patch the templatized manifests by replacing the labels with template anchors with static values.
This is ugly but it works (having plain manifests will always better though), FluxCD is happy and the CRDs are deployed :
Hello @hawksight, here is the link to the documentation about this feature : https://fluxcd.io/flux/components/kustomize/kustomization/#health-checks
For now, I use something like this in my CRDs kustomization in FluxCD, this works fine :
For other operators available here, I use the healthcheck feature like this :
I just don’t see how to do it with Cert-Manager CRDs with a single link, but to be completely transparent, I’m by no mean a FluxCD guru, maybe there is an another way to do it 😃
Agreed. Helm now recommends putting crds in the
crdsfolder of the chart. Would rather not have a separate chart for CRDs.Sounds great! Thanks for pushing this forward when I fell off after a while.
But this still doesn’t fix https://github.com/cert-manager/cert-manager/issues/6179#issuecomment-1764051690
Additionally, as @michaelajr already said, helm recommends putting the CRDs in the
crdsfolder.And to quote myself; if you’re doing gitops, the
crdsfolder works perfectly and if you’re doing it manually, you might as wellapplythecrdsfolder 🤷Since it’s just the labels that are templated, you can use spec.commonMetadata instead of patches. It makes the kustomzation a bit cleaner looking.
@hawksight Yep, that’s why I use the complete YAML file you linked with all CRDs bundled as a workaround. But as I mentioned at first when writing into this issue, the usage of this direct link doesn’t allow me to use the FluxCD healthcheck feature.
If you look at it closely, when using the single link, I use a kustomization with a kind of
kustomize.config.k8s.io/v1beta1to include all of my sub-files that include custom resources (see my Traefik example). When I want to use the healthcheck feature, the kustomization is a kind ofkustomize.toolkit.fluxcd.io/v1, because it’s handled by a custom FluxCD controller with additional features including healthcheck.Having a separate CRD folder with plain manifests without templating (inside or outside of the Helm charts) is convenient for tools like FluxCD from my point of view as a user, but I don’t know the implications on cert-manager side. For Traefik, I use the CRDs located inside the Helm chart and I disabled their management by Helm in my
HelmReleasedefinition in Flux :Since it looks like it’s a recommended practice to manage CRD outside of Helm (also mentioned in your documentation for production deployments), I used this general idea for all of my controller deployments including MetalLB, Kyverno or OpenEBS.
Yep, I found these CRDs, but the problem is they are templatized. However, for managing CRDs I don’t use the HelmRelease reconciliation in FluxCD, but a Kustomization reconciliation which uses kustomize under the hood.
That’s mainly the problem since I don’t see how I can provide the required values for the template with this and therefore applying the manifests correctly (I don’t find anything in the FluxCD documentation to substitute Helm template anchors with a Kustomization). If these CRDs weren’t templatized, this will solve the problem since my kustomization reconciliation will simply apply plain manifests like I did for Traefik, and then I can use healthchecks on these CRDs afterwards.
As an example for Traefik, I simply asked the Kustomization reconciliation to pull CRDs in the Traefik Helm chart and apply them as-is. Since these are plain CRDs manifests, this works perfectly and is very simple to manage.
One dirty hack I could use is kustomization patches and replace templatized metadata labels with static values. I’m not sure this will works, I need to test it.
Updating CRDs is definitely a challenge when they are put into the
crdsfolder. The pattern we follow for charts with CRDs is to do akubectl apply -f path/to/crdsbefore thehelm update. This ensures any CRD updates are captured.Additionally, having them in the
crdsfolder - and not templated in the Helm chart - allows things to continue to work if the component is ever removed. We’ve run into this when upgrading ArgoCD. Had to remove it first. But because theApplicationandProjectCRDs and CRs remained - there were no issues.I understand the dilemma maintainers have a round this. No easy answer.
Thanks for the input on this issues. There are some other considerations and difference with helm that we have documented here.
tl;dr our CRDs can change and we want them to be in sync with the components. Helm’s crds folder doesn’t allow uprading / removal etc.
I’m not sure I understand the problem precisely, is it that:
crddirectory in the helm chart (we do not do this).?@bradenwright - what is your automation? Is it outputting that message as an actual blocking error, or as a warning? As a workaround, you could apply the CRDs as YAML directly and use the chart for cert-manager without the
installCRDsflag being set?@f-bn could you link to the flux healthcheck feature for CRDs please? Interested to see what that requires.