Skip to content

Commit e41dc2f

Browse files
committed
feat(helm): add podLabels for the chart's pods
A multi-tenant telemetry collector commonly takes a pod's tenant from a pod label, the one signal a headerless OTLP export carries. The chart sets only its own `app` label on every pod and offers no way to add one. `podLabels` is added to every long-running pod template, next to `app`, which it cannot replace: `app` is the selector of every workload, so the render fails when podLabels sets it. The rustfs-bucket-init Job is left out, because a Job's pod template is immutable and a label change would fail the upgrade. The substrate-podcert chart takes its own `podLabels` for the podcertificate-controller pod, under the same rule. The default render is unchanged, so manifests/ate-install/ stays as is. Signed-off-by: QuentinBisson <quentin@giantswarm.io>
1 parent 9c4b1fb commit e41dc2f

14 files changed

Lines changed: 51 additions & 0 deletions

‎charts/substrate-podcert/README.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ Configure the controller image through `image.registry`, `image.repository`,
3737
and `image.tag`. `global.imageRegistry` overrides the registry, and
3838
`imagePullSecrets` and `global.imagePullSecrets` are merged for the controller pod.
3939

40+
`podLabels` adds labels to the controller pod, next to its `app` label, which
41+
they cannot replace.
42+
4043
For an existing installation, the controller resources must be transferred out
4144
of the application release before the new release can own them. Installing this
4245
chart over resources still owned by the application release fails Helm ownership

‎charts/substrate-podcert/templates/_helpers.tpl‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,17 @@ imagePullSecrets:
4646
{{- toYaml $merged | nindent 0 }}
4747
{{- end -}}
4848
{{- end -}}
49+
50+
{{/*
51+
The podLabels entries for the controller's pod template, as YAML map entries.
52+
Renders nothing when podLabels is empty. `app` is the Deployment's selector
53+
label, so a podLabels entry cannot replace it.
54+
*/}}
55+
{{- define "podcert.podLabels" -}}
56+
{{- with .Values.podLabels -}}
57+
{{- if hasKey . "app" -}}
58+
{{- fail "podLabels must not set app: it is the selector label of the controller Deployment" -}}
59+
{{- end -}}
60+
{{- toYaml . -}}
61+
{{- end -}}
62+
{{- end -}}

‎charts/substrate-podcert/templates/pod-certificate-controller.yaml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ spec:
149149
metadata:
150150
labels:
151151
app: podcertificate-controller
152+
{{- with include "podcert.podLabels" . }}{{- . | nindent 8 }}{{- end }}
152153
spec:
153154
{{- with include "podcert.imagePullSecrets" . }}{{- . | nindent 6 }}{{- end }}
154155
containers:

‎charts/substrate-podcert/values.yaml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ global:
3838
imageRegistry: ""
3939
imagePullSecrets: []
4040

41+
# Labels added to the controller pod, next to its own `app` label, which they
42+
# cannot replace.
43+
podLabels: {}
44+
4145
imagePullSecrets: []
4246
image:
4347
registry: ghcr.io

‎charts/substrate/README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ See `values.yaml` for the full set; the important keys:
6666
| `atelet.imageCredentialProviderBinDir` | `""` | Host path to the kubelet credential provider binaries; both paths are mounted read-only |
6767
| `credentialProvider.namespacePolicies` | `[]` | Default-deny atespace-to-namespace grants; the chart includes get-only Secret RBAC for the provider |
6868
| `ateApi.extraArgs` | `[]` | Additional command-line arguments appended to the ateapi defaults |
69+
| `podLabels` | `{}` | Labels added to every long-running pod, next to the chart's own `app` label |
6970
| `otel.endpoint` | `""` | Set to an OTLP endpoint to export traces, metrics, the actor lifecycle events and the router access log |
7071
| `otel.traces.enabled` | `true` | Set to `false` to export no traces from the router; the Go components do not honor this yet |
7172
| `otel.traces.endpoint` | `""` | OTLP endpoint for traces, overriding `otel.endpoint` |

‎charts/substrate/templates/_helpers.tpl‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,20 @@ imagePullSecrets:
226226
{{- end -}}
227227
{{- end -}}
228228

229+
{{/*
230+
The podLabels entries for a pod template, as YAML map entries. Renders nothing
231+
when podLabels is empty. The chart's own `app` label is the selector of every
232+
workload, so a podLabels entry cannot replace it.
233+
*/}}
234+
{{- define "substrate.podLabels" -}}
235+
{{- with .Values.podLabels -}}
236+
{{- if hasKey . "app" -}}
237+
{{- fail "podLabels must not set app: it is the selector label of every workload in the chart" -}}
238+
{{- end -}}
239+
{{- toYaml . -}}
240+
{{- end -}}
241+
{{- end -}}
242+
229243
{{/*
230244
imagePullPolicy: global.imagePullPolicy when set, IfNotPresent otherwise. One
231245
definition so the fallback cannot drift between pods.

‎charts/substrate/templates/ate-api-server.yaml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ spec:
7474
metadata:
7575
labels:
7676
app: ate-api-server
77+
{{- with include "substrate.podLabels" $ }}{{- . | nindent 8 }}{{- end }}
7778
annotations:
7879
prometheus.io/scrape: "true"
7980
prometheus.io/port: "9090"

‎charts/substrate/templates/ate-controller.yaml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ spec:
6565
metadata:
6666
labels:
6767
app: ate-controller
68+
{{- with include "substrate.podLabels" $ }}{{- . | nindent 8 }}{{- end }}
6869
spec:
6970
serviceAccountName: {{ include "substrate.fullname" (list "ate-controller" .) }}
7071
{{- with include "substrate.imagePullSecrets" . }}{{- . | nindent 6 }}{{- end }}

‎charts/substrate/templates/atelet.yaml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ spec:
123123
metadata:
124124
labels:
125125
app: atelet
126+
{{- with include "substrate.podLabels" $ }}{{- . | nindent 8 }}{{- end }}
126127
annotations:
127128
prometheus.io/scrape: "true"
128129
prometheus.io/port: "9090"

‎charts/substrate/templates/atenet-egress.yaml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ spec:
126126
metadata:
127127
labels:
128128
app: atenet-egress
129+
{{- with include "substrate.podLabels" $ }}{{- . | nindent 8 }}{{- end }}
129130
spec:
130131
serviceAccountName: {{ include "substrate.fullname" (list "atenet-egress" .) }}
131132
securityContext:

0 commit comments

Comments
 (0)