BUG REPORT
Any Chart containing Deployment/StatefulSet/DaemonSet apps/v1beta1 or extensions/v1beta1 without spec.selector using a chart version in metadata.labels can't be upgraded.
Note:
This is the first bug among 3 regarding "I can't upgrade my Release".
For the apps/v1beta2 problem, see https://github.com/helm/charts/issues/7680.
For the immutable volumeClaimTemplate in StatefulSet (any version), see #7803
spec.metadata.labelsSource: Official documentation: https://v1-7.docs.kubernetes.io/docs/concepts/workloads/controllers/deployment/
If .spec.selector is unspecified, .spec.selector.matchLabels defaults to .spec.template.metadata.labels
Probably all of https://github.com/helm/charts/pulls?utf8=%E2%9C%93&q=is%3Apr+%22Add+chart+and+release+labels+in+pods%22+
Let's install the stable/dokuwiki chart using git, change the version in chart.yaml (example: 1.2.3 -> 1.2.4) without changing anything else, and try to upgrade. See it fail:
cd stable/dokuwiki
helm install --name test .
vim Chart.yaml
helm upgrade test .
Because of metadata.labels in templates/deployment.yaml containing:
chart: {{ template "dokuwiki" . }}
It will fail with:
Error: UPGRADE FAILED: Deployment.apps "test-dokuwiki" is invalid: spec.template.metadata.labels: Invalid value: map[string]string{"release":"test", "app":"dokuwiki", "chart":"dokuwiki-2.0.7"}: `selector` does not match template `labels`
I think it comes from the fact that during the initial installation, k8s generated the selector, but during upgrade, both helm and k8s ignore it.
But putting an explicit selector, even if it contains a chart label, will make it upgradable:
selector:
matchLabels:
app: {{ template "dokuwiki.name" . }}
chart: {{ template "dokuwiki.chart" . }}
release: {{ .Release.Name | quote }}
helm upgrade test .
It works!
chart label although it would be not wise as it would break compatibility for apps/v1beta2 and later (see #7680 )spec.template.metadata.labels are not impacted.Thankfully, this can be solved using a minor version change.
cc @mattfarina @davidkarlsen @scottrigby @javsalgar @carrodher
Hi @desaintmartin Thanks again for working to unpack these related issues.
Just to disambiguate these two issues, are you essentially saying this?
apps/v1beta1 or extensions/v1beta1 require explicitly adding match labels - including the mutable chart label (this issue, #7726).>=apps/v1 require removing any mutable labels from spec.selector, specifically chart (#7680).If so, should we clarify this in #7692?
And can this issue should clarify this line in the "Conclusion":
set selector everywhere and don't put mutable fields in it (for forward compatibility)
For this issue (resources in apps/v1beta1 or extensions/v1beta1), it sounds like "set selector everywhere" is correct, but adding a mutable fields is exactly what we want them to do here?
Hey @scottrigby, just helping!
You are correct, except that, in my understanding, the immutability comes with apps/v1beta2 and later, and not only apps/v1. Any confirmation or invalidation would be appreciated! :)
Let me clarify the conclusion by clearly separating the two problems, i.e what should be done now (apps/v1beta1 or extensions/v1beta1) and what is nice for the future (>=v1beta2).
Regarding #7692, I didn't want to get into the details of "why" but let's try, let's continue there for this part of the discussion.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Any further update will cause the issue/pull request to no longer be considered stale. Thank you for your contributions.
Have all charts been updated? Can we close this?
Charts owned by Bitnami were updated
I've also encountered this issue in the stable/mongodb chart. It doesn't appear to be fixed yet (https://github.com/helm/charts/tree/master/stable/mongodb).
It is related to https://github.com/helm/charts/issues/7680 to be exact, thanks for reporting.
MongoDB chart was fixed on this PR: https://github.com/helm/charts/pull/10121
We can close this issue because we have the correct way to handle this documented in the Names and Labels section of the REVIEW_GUIDELINES.
If we want to automate checking for this, we should add to https://github.com/helm/chart-testing 馃槃
Most helpful comment
Hey @scottrigby, just helping!
You are correct, except that, in my understanding, the immutability comes with
apps/v1beta2and later, and not onlyapps/v1. Any confirmation or invalidation would be appreciated! :)Let me clarify the conclusion by clearly separating the two problems, i.e what should be done now (
apps/v1beta1orextensions/v1beta1) and what is nice for the future (>=v1beta2).Regarding #7692, I didn't want to get into the details of "why" but let's try, let's continue there for this part of the discussion.