2. Recommended labels via a shared helper; immutable selector labels
Date: 2026-06-24
Status
Accepted
Context
The original templates repeated four ad-hoc labels (app, chart, release,
heritage) inline on every object, and used app + release as the
Deployment/StatefulSet selector.matchLabels. Two problems:
- The chart did not carry the Kubernetes-recommended
app.kubernetes.io/*labels that tooling (dashboards, kubectl, operators) expects. - A workload's
selector.matchLabelsis immutable after creation. Changing it on an existing release fails the upgrade.
Decision
Centralize labels in two helpers in _helpers.tpl:
docker-registry.match-labels— onlyapp+release. Used for allselector.matchLabelsand Service/Monitor selectors. Never changed, so upgrades from upstream remain valid.docker-registry.labels— the match-labels plus chart metadata and the recommended set (app.kubernetes.io/name,/instance,/managed-by,/version,helm.sh/chart). Used formetadata.labels.
Consequences
- Objects gain the recommended labels without changing the immutable selectors,
so
helm upgradefrom upstream 3.0.0 is non-disruptive. - Label content is defined once; templates call the helper.
- The selector deliberately excludes
app.kubernetes.io/*to preserve immutability — see the note in_helpers.tpl. Tests assert the selector staysapp+releaseonly.