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

Removing crd from the cluster when helmfile apply #341

Open
maks1001281 opened this issue Apr 15, 2024 · 2 comments
Open

Removing crd from the cluster when helmfile apply #341

maks1001281 opened this issue Apr 15, 2024 · 2 comments

Comments

@maks1001281
Copy link

maks1001281 commented Apr 15, 2024

Hi all, I have a problem understanding helm diff and removing crds from kubernetes cluster when helm apply

I have a helmfile which contains 2 charts, the first chart contains crds and other templates and the second one contains crunchy-postgres cluster configuration description, I have clustered these charts in the cluster and everything was working, but there was a need to update and remove crds in a separate chart, for this I released a new tag for the first chart which includes only template files, and released a new chart that includes only the new crds, after applying helmfile -e cpdev diff helm complained that it expects the release-name field with the value crunchy-postgres-operator in the new crds, which was logical since the new chart was now called crunchy-postgres-operator-crds and the current release did not manage it, it was decided to patch the old crd with the command

kubectl patch crds postgresclusters.postgres-operator.crunchydata.com -p '{"metadata":{"annotations":{"meta.helm. sh/release-name": "crunchy-postgres-operator-crds", "meta.helm.sh/release-namespace": "crunchy-postgres"}, "labels":{"app.kubernetes.io/managed-by": "Helm"}}}''

After the patch I saw a normal diff that showed that it removes the old crd and applies the new one, I did helmfile apply and got the crunchy-postgres-operator update, but when updating the operator there were errors and I had to roll back to the old crd and operator version while keeping crunchy-postgres working, I commented out the lines that are associated with the separate chart that only includes crds and changed the tag in the first chart to the old one that includes the template files and the crds files, when applying the helmfile apply I saw that the helmfile expects the old name in the release-name field with the value crunchy-postgres-operator.
I patched the new crds to the old fields so that the helmfile would manage it.

kubectl patch crds postgresclusters.postgres-operator.crunchydata.com -p '{"metadata":{"annotations":{"meta.helm. sh/release-name": "crunchy-postgres-operator", "meta.helm.sh/release-namespace": "crunchy-postgres"}, "labels":{"app.kubernetes.io/managed-by": "Helm"}}}''

I applied helmfile diff and saw that old crds are not deleted but only new crds come in, ok I thought, I did helmfile apply and crd was deleted, and since crd deletion deletes all crd related resources my crunchy-postgres cluster with all bases was deleted, why helmfile deleted crd even though it didn't show it in helmfile diff? How helmfile works with crds and why this situation happened?

@chcshinimai
Copy link

The same thing is happening when I applied the latest dynatrace-oprator chart version 1.3.2.
When I applied version 1.2.3, it was fine. When I generate template with helmfile template on version 1.3.2, I can see CRDs are also templated. However, when I apply the chart, it deletes all CRDs.

@gjenkins8
Copy link
Member

For functionality related to Helmfile, please post an issue over on https://github.com/helmfile/helmfile. Thanks!

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

No branches or pull requests

3 participants