Skip to content

fix(labels): keep the chart version out of the pod labels - #2075

Merged
traefiker merged 3 commits into
traefik:masterfrom
DrFaust92:fix-pod-labels-chart-version
Nov 23, 2026
Merged

traefiker merged 3 commits into
traefik:masterfrom
DrFaust92:fix-pod-labels-chart-version

Conversation

@DrFaust92

@DrFaust92 DrFaust92 commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

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. 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, so kubectl get deploy -L helm.sh/chart is unaffected.

Measured by rendering the chart at its own version and at 99.99.99 and diffing the pod templates:

chart pod templates changed on a chart version bump (before → after)
traefik 1 1 → 0
hub-manager 2 2 → 1 (the remaining one is a hook Job, see below)

Before, the whole difference was the label itself:

-    helm.sh/chart: traefik-42.3.0
+    helm.sh/chart: traefik-99.99.99

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):

  1. Pod labels: helm.sh/chart is 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 on helm.sh/chart (NetworkPolicies, PodMonitors, kubectl -l, etc.) stop matching and should use app.kubernetes.io/name and app.kubernetes.io/instance instead, with PR fix(labels): keep the chart version out of the pod labels #2075.

More

app.kubernetes.io/version deliberately stays on pods. Unlike helm.sh/chart, it is accurate: it resolves through traefik.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:

set:
  image.tag: v3.7.10
chart:
  version: 99.99.99
asserts:
  - equal:
      path: spec.template.metadata.labels["app.kubernetes.io/version"]
      value: v3.7.10
  - equal:
      path: spec.template.spec.containers[0].image
      value: docker.io/traefik:v3.7.10

That case passes on master too — it is there so a later change cannot quietly turn this label into chart metadata.

The selector is safe. spec.selector.matchLabels uses traefik.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-map equal pins the default set so another chart-derived label cannot be added later without a test noticing.

hub-manager had the same issue, so it gets the same treatment for its Deployment — .github/chart-testing.yaml is linted with --charts traefik/,hub-manager/, so the two travel together. Its migration Job is deliberately left alone: it is a pre-install,pre-upgrade hook with before-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.yaml is untouched: version bumps and artifacthub.io/changes land in the chore(release) commit, not in contributor PRs. values.yaml is untouched too, so VALUES.md and values.schema.json need no regeneration.

  • Yes, I updated the tests accordingly — new traefik/tests/pod-labels_test.yaml (6 cases) and hub-manager/tests/pod-labels_test.yaml (4 cases). Written first, per AGENTS.md: against master 3 of 6 and 2 of 4 fail respectively; the rest are invariants kept as regression guards.
  • Yes, I updated the schema accordingly — not applicable, no values changed.
  • Yes, I ran make test and all the tests passed — traefik 54 suites / 854 tests, hub-manager 7 suites / 37 tests, plus helm lint. I ran the two helm unittest commands from hack/test.sh directly rather than the wrapper.

This PR was prepared with AI assistance.

@mloiseleur mloiseleur left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 create convention.

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/version cases already pass on master and guard behaviour this PR doesn't change. Keeping the notExists cases and the whole-map equal is 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.

@mloiseleur mloiseleur added the kind/proposal a proposal that needs to be discussed. label Nov 6, 2026
@DrFaust92

Copy link
Copy Markdown
Contributor Author

Thanks. Nits applied: one comment line per helper, and the tests are down to the notExists cases plus the whole-map equal.

On the direction, the same change has already been merged in a number of widely used charts, so helm.sh/chart off the pod template is becoming the norm rather than a departure:

The related fix for checksum/* annotations hashing the whole manifest (labels included) landed in open-telemetry/opentelemetry-helm-charts#2402 and Altinity/clickhouse-operator#2079.

Agreed on the release note: it rolls pods once on the upgrade that ships it, and any selector on helm.sh/chart would stop matching pods.

@DrFaust92
DrFaust92 force-pushed the fix-pod-labels-chart-version branch from 29a3a21 to b6921f1 Compare November 22, 2026 12:48

@mloiseleur mloiseleur left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @DrFaust92!

@mloiseleur

Copy link
Copy Markdown
Member

Needs second review.

@darkweaver87 darkweaver87 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks :-)

DrFaust92 and others added 3 commits November 23, 2026 15:35
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>
@mloiseleur
mloiseleur force-pushed the fix-pod-labels-chart-version branch from b6921f1 to dc3b56c Compare November 23, 2026 14:35
@traefiker
traefiker merged commit ac23211 into traefik:master Nov 23, 2026
2 checks passed
unbeholdendev pushed a commit to unbeholdendev/infra that referenced this pull request Nov 24, 2026
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 [#&#8203;2075](traefik/traefik-helm-chart#2075).
2. **hostIP**: `ports.<name>.hostIP` binds the entrypoint and probes only with `hostNetwork` enabled, with PR [#&#8203;2110](traefik/traefik-helm-chart#2110).

#### 🚀 Features

- feat(deps): update ghcr.io/traefik/hub-manager docker tag to v0.46.2 [#&#8203;2117](traefik/traefik-helm-chart#2117) by [@&#8203;renovate-with-github-actions](https://github.com/renovate-with-github-actions)\[bot]
- feat(hub): 🚀 support traefik hub v3.21.13 [#&#8203;2119](traefik/traefik-helm-chart#2119) by [@&#8203;mloiseleur](https://github.com/mloiseleur)

#### 🐛 Bug fixes

- fix(ports): only use hostIP for entrypoint binding with hostNetwork [#&#8203;2110](traefik/traefik-helm-chart#2110) by [@&#8203;RedaMG1](https://github.com/RedaMG1)
- fix(labels): keep the chart version out of the pod labels [#&#8203;2075](traefik/traefik-helm-chart#2075) by [@&#8203;DrFaust92](https://github.com/DrFaust92)

#### 📦 Others

- chore(deps): update github actions [#&#8203;2118](traefik/traefik-helm-chart#2118) by [@&#8203;renovate-with-github-actions](https://github.com/renovate-with-github-actions)\[bot]
- chore(release): 🚀 publish 42.4.2 [#&#8203;2120](traefik/traefik-helm-chart#2120) by [@&#8203;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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants