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

Helm2 to Helm3 migration #2451

Closed
AlexShemeshWix opened this issue Dec 11, 2019 · 7 comments
Closed

Helm2 to Helm3 migration #2451

AlexShemeshWix opened this issue Dec 11, 2019 · 7 comments
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@AlexShemeshWix
Copy link

Describe the bug:
Migrating cert-manager helm chart from helm2 to helm3 is not working.

Expected behaviour:
There are no differences except for "app.kubernetes.io/managed-by":"Helm" and it should upgrade without problem

Steps to reproduce the bug:
Ive installed version v0.12.0 of cert-manager helm chart with helm2
Ive migrated helm releases using helm3 2to3 convert command.
When i run helm3 upgrade i have following error message

wix-cert-manager
in ./helmfile.yaml: failed processing release wix-cert-manager: helm3 exited with status 1:
  Error: UPGRADE FAILED: cannot patch "wix-cert-manager-cainjector" with kind Deployment: Deployment.apps "wix-cert-manager-cainjector" is invalid: spec.selector: Invalid value: v1.LabelSelector{MatchLabels:map[string]string{"app":"cainjector", "app.kubernetes.io/instance":"wix-cert-manager", "app.kubernetes.io/managed-by":"Helm", "app.kubernetes.io/name":"cainjector"}, MatchExpressions:[]v1.LabelSelectorRequirement(nil)}: field is immutable && cannot patch "wix-cert-manager" with kind Deployment: Deployment.apps "wix-cert-manager" is invalid: spec.selector: Invalid value: v1.LabelSelector{MatchLabels:map[string]string{"app":"cert-manager", "app.kubernetes.io/instance":"wix-cert-manager", "app.kubernetes.io/managed-by":"Helm", "app.kubernetes.io/name":"cert-manager"}, MatchExpressions:[]v1.LabelSelectorRequirement(nil)}: field is immutable && cannot patch "wix-cert-manager-webhook" with kind Deployment: Deployment.apps "wix-cert-manager-webhook" is invalid: spec.selector: Invalid value: v1.LabelSelector{MatchLabels:map[string]string{"app":"webhook", "app.kubernetes.io/instance":"wix-cert-manager", "app.kubernetes.io/managed-by":"Helm", "app.kubernetes.io/name":"webhook"}, MatchExpressions:[]v1.LabelSelectorRequirement(nil)}: field is immutable

Anything else we need to know?:
i can destroy converted release and redeploy it from helm3 and it will work ok.

Environment details::
kube v1.15.6
helm2 v2.16.1
helm3 v3.0.0
cert-manager v0.12.0

/kind bug

@jetstack-bot jetstack-bot added the kind/bug Categorizes issue or PR as related to a bug. label Dec 11, 2019
@deiga
Copy link

deiga commented Dec 13, 2019

@AlexShemeshWix There is not much that jetstack can do to fix this, as any changes to the charts will cause the same error. Kube limits specific fields as immutable.

I found a workaround which is to manually edit the 3 deployments generated cert-manager, cert-manager-cainjector and cert-manager-webhook and replace Tiller with Helm.
Then upgrading works after that

@AlexShemeshWix
Copy link
Author

Yes thats what i ended up doing. Not very efficient

@deiga
Copy link

deiga commented Dec 13, 2019

True, but this is not really a bug in Helm or the Chart.
The Chart probably should not use label selectors which might change this way, but this change shouldn't happen too often

@venkatalolla
Copy link

I ran into the same issue, it seems like if we migrate an existing release and there is a selector/label set to app.kubernetes.io/managed-by: {{ .Release.Service }} it fails, I have 20 deployments running through Helm and changing each deployments label is not a feasible solution.

@diversario
Copy link
Contributor

The right solution to this would be to not use app.kubernetes.io/managed-by label in a LabelSelector context. This specific label doesn't add anything to the selector anyway, since there are already

      app: {{ include "cainjector.name" . }}
      app.kubernetes.io/name: {{ include "cainjector.name" . }}
      app.kubernetes.io/instance: {{ .Release.Name }}

labels that target this release.

@Dylan-DutchAndBold
Copy link

Dylan-DutchAndBold commented Feb 7, 2020

I have written a few simple string replacement commands to fix this issue. Hope this helps.

kubectl get deployment/cert-manager -o yaml -n cert-manager | sed "s/Tiller/Helm/g" | kubectl replace --force=true -f -

kubectl get deployment/cert-manager-cainjector -o yaml -n cert-manager | sed "s/Tiller/Helm/g" | kubectl replace --force=true -f -

kubectl get deployment/cert-manager-webhook -o yaml -n cert-manager | sed "s/Tiller/Helm/g" | kubectl replace --force=true -f -

@munnerz
Copy link
Member

munnerz commented Apr 23, 2020

We have removed this label now as part of our selector, so this shouldn't come up again. As noted before, we sadly can't do anything to help those on older versions trying to upgrade.

@munnerz munnerz closed this as completed Apr 23, 2020
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

7 participants