Repository navigation
fix(labels): keep the chart version out of the pod labels - #2075
Conversation
There was a problem hiding this comment.
Thanks, I get your point. It may be interesting to proceed that way.
I checked Helm: helm.sh/chart is only written by the helm create scaffold, never read. helm list/status/history/rollback use the release Secrets, so nothing in Helm depends on it being on pods. Objects keep the label, so kubectl get -L still works.
Two points to consider:
- It breaks pod selectors on
helm.sh/chart(unlikely) and rolls all pods once. Both need a release note. - It departs from the
helm createconvention.
Nits:
- One comment line per helper is enough, e.g.
{{/* traefik.labels without helm.sh/chart, to avoid pod restarts on chart-only upgrades */}}. - Tests: the selector and
app.kubernetes.io/versioncases already pass on master and guard behaviour this PR doesn't change. Keeping thenotExistscases and the whole-mapequalis enough.
We’re unsure of the direction to take on this. We are going to leave the status as kind/proposal to give the community time to let us know if they would like this idea.
We will reevaluate as people respond.
|
Thanks. Nits applied: one comment line per helper, and the tests are down to the On the direction, the same change has already been merged in a number of widely used charts, so
The related fix for Agreed on the release note: it rolls pods once on the upgrade that ships it, and any selector on |
29a3a21 to
b6921f1
Compare
|
Needs second review. |
traefik.labels includes helm.sh/chart, and _podtemplate.tpl applies the full set to the pod template as well as to the object. That label carries the chart version, so every pod is recreated on a chart upgrade even when neither the image nor the configuration changed. Since the pod template is shared, this affects both the Deployment and the DaemonSet. This adds traefik.podlabels, the same set without that one key, and uses it in the pod template. Objects keep the full set, so kubectl get deploy -L helm.sh/chart is unaffected. app.kubernetes.io/version stays on pods: it resolves through traefik.appVersion, which tracks the running image rather than chart metadata, so it is accurate and already changes only when the image does. The selector is traefik.labelselector, app.kubernetes.io/name and app.kubernetes.io/instance, both of which remain on the pod template, so the immutable selector still matches. hub-manager has the same issue and gets the same treatment for its Deployment. Its migration Job is left alone: it is a pre-install,pre-upgrade hook with before-hook-creation,hook-succeeded, so it is recreated on every upgrade regardless and the label costs nothing there.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
b6921f1 to
dc3b56c
Compare
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [traefik](https://traefik.io/) ([source](https://github.com/traefik/traefik-helm-chart)) | HelmChart | patch | `42.4.1` → `42.4.2` | --- ### Release Notes <details> <summary>traefik/traefik-helm-chart (traefik)</summary> ### [`v42.4.2`](https://github.com/traefik/traefik-helm-chart/releases/tag/v42.4.2) [Compare Source](traefik/traefik-helm-chart@v42.4.1...v42.4.2) **Upgrade Notes** 1. **Pod labels**: `helm.sh/chart` is removed from pods. Pod selectors on `helm.sh/chart` must use `app.kubernetes.io/name` and `app.kubernetes.io/instance` instead, with PR [#​2075](traefik/traefik-helm-chart#2075). 2. **hostIP**: `ports.<name>.hostIP` binds the entrypoint and probes only with `hostNetwork` enabled, with PR [#​2110](traefik/traefik-helm-chart#2110). #### 🚀 Features - feat(deps): update ghcr.io/traefik/hub-manager docker tag to v0.46.2 [#​2117](traefik/traefik-helm-chart#2117) by [@​renovate-with-github-actions](https://github.com/renovate-with-github-actions)\[bot] - feat(hub): 🚀 support traefik hub v3.21.13 [#​2119](traefik/traefik-helm-chart#2119) by [@​mloiseleur](https://github.com/mloiseleur) #### 🐛 Bug fixes - fix(ports): only use hostIP for entrypoint binding with hostNetwork [#​2110](traefik/traefik-helm-chart#2110) by [@​RedaMG1](https://github.com/RedaMG1) - fix(labels): keep the chart version out of the pod labels [#​2075](traefik/traefik-helm-chart#2075) by [@​DrFaust92](https://github.com/DrFaust92) #### 📦 Others - chore(deps): update github actions [#​2118](traefik/traefik-helm-chart#2118) by [@​renovate-with-github-actions](https://github.com/renovate-with-github-actions)\[bot] - chore(release): 🚀 publish 42.4.2 [#​2120](traefik/traefik-helm-chart#2120) by [@​mloiseleur](https://github.com/mloiseleur) #### 👌 Traefik version support - Traefik Proxy: v3.6.0 -> v3.7.19 (default) - Traefik Hub: v3.19.3 -> v3.21.13 </details> --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate CLI](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4yNTcuOSIsInVwZGF0ZWRJblZlciI6IjQ0LjI1Ny45IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119--> Reviewed-on: https://git.home.unbeholden.dev/unbeholden/infra/pulls/185
What does this PR do?
traefik.labelsincludeshelm.sh/chart, and_podtemplate.tplapplies the full set to the pod template as well as to the object. That label carries the chart version, so every pod is recreated on a chart upgrade even when neither the image nor the configuration changed. Because the pod template is shared, it affects the Deployment and the DaemonSet alike.This adds
traefik.podlabels— the same set without that one key — and uses it in the pod template. Objects keep the full set, sokubectl get deploy -L helm.sh/chartis unaffected.Measured by rendering the chart at its own version and at
99.99.99and diffing the pod templates:traefikhub-managerBefore, the whole difference was the label itself:
Motivation
A chart release that changes neither the image nor the config currently rolls every Traefik pod. On a DaemonSet that is one restart per node, and on an ingress controller each restart is a brief drop in proxying capacity, so the cost is paid at exactly the wrong layer.
Upgrade notes
Proposed entry for the Upgrade Notes of the release that ships this (the changelog is generated from commit titles, so the note goes here for the release commit):
helm.sh/chartis no longer set on the Traefik and hub-manager pod templates (it stays on the Deployment, DaemonSet, Service and other objects). The upgrade that ships this rolls every Traefik (and hub-manager) pod once; later chart-only upgrades no longer restart pods. Selectors that match pods onhelm.sh/chart(NetworkPolicies, PodMonitors,kubectl -l, etc.) stop matching and should useapp.kubernetes.io/nameandapp.kubernetes.io/instanceinstead, with PR fix(labels): keep the chart version out of the pod labels #2075.More
app.kubernetes.io/versiondeliberately stays on pods. Unlikehelm.sh/chart, it is accurate: it resolves throughtraefik.appVersion→traefik.proxyVersion, which tracks the running image rather than chart metadata. It therefore already changes only when the image changes — which is a restart you want. I pinned this in a test rather than asserting it:That case passes on
mastertoo — it is there so a later change cannot quietly turn this label into chart metadata.The selector is safe.
spec.selector.matchLabelsusestraefik.labelselector, which the helper comments already mark as immutable; both of its keys stay on the pod template, so the selector still matches. A test asserts the pod labels and the selector agree rather than leaving it to inspection.Nothing else is dropped.
commonLabels,deployment.podLabels, the Azure usage label and the Hub cert hash all still render. A whole-mapequalpins the default set so another chart-derived label cannot be added later without a test noticing.hub-managerhad the same issue, so it gets the same treatment for its Deployment —.github/chart-testing.yamlis linted with--charts traefik/,hub-manager/, so the two travel together. Its migration Job is deliberately left alone: it is apre-install,pre-upgradehook withbefore-hook-creation,hook-succeeded, so it is deleted and recreated on every upgrade regardless of its labels, and the chart version on a hook pod is useful when debugging a failed upgrade. That is the one pod template still listed as changing in the table above.Upgrading rolls every Traefik pod once, as the pod template changes for the last time. After that a chart release on its own no longer restarts anything.
Chart.yamlis untouched: version bumps andartifacthub.io/changesland in thechore(release)commit, not in contributor PRs.values.yamlis untouched too, soVALUES.mdandvalues.schema.jsonneed no regeneration.traefik/tests/pod-labels_test.yaml(6 cases) andhub-manager/tests/pod-labels_test.yaml(4 cases). Written first, perAGENTS.md: againstmaster3 of 6 and 2 of 4 fail respectively; the rest are invariants kept as regression guards.make testand all the tests passed —traefik54 suites / 854 tests,hub-manager7 suites / 37 tests, plushelm lint. I ran the twohelm unittestcommands fromhack/test.shdirectly rather than the wrapper.This PR was prepared with AI assistance.