Skip to content

Commit 1ec7ada

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 c2edd34 commit 1ec7ada

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
@@ -73,6 +73,7 @@ See `values.yaml` for the full set; the important keys:
7373
| `ateApi.logLevel` | `info` | API server log level in its mounted config; one of `debug`, `info`, `warn`, or `error` |
7474
| `ateApi.authorization.bootstrapOwners` | `[]` | Global owners; empty defaults to the release's shared `ate-client` ServiceAccount |
7575
| `ateApi.extraArgs` | `[]` | Additional command-line arguments appended to the ateapi defaults |
76+
| `podLabels` | `{}` | Labels added to every long-running pod, next to the chart's own `app` label |
7677
| `otel.endpoint` | `""` | Set to an OTLP endpoint to export traces, metrics, the actor lifecycle events and the router access log |
7778
| `otel.traces.enabled` | `true` | Set to `false` to export no traces from the router; the Go components do not honor this yet |
7879
| `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
@@ -231,6 +231,20 @@ imagePullSecrets:
231231
{{- end -}}
232232
{{- end -}}
233233

234+
{{/*
235+
The podLabels entries for a pod template, as YAML map entries. Renders nothing
236+
when podLabels is empty. The chart's own `app` label is the selector of every
237+
workload, so a podLabels entry cannot replace it.
238+
*/}}
239+
{{- define "substrate.podLabels" -}}
240+
{{- with .Values.podLabels -}}
241+
{{- if hasKey . "app" -}}
242+
{{- fail "podLabels must not set app: it is the selector label of every workload in the chart" -}}
243+
{{- end -}}
244+
{{- toYaml . -}}
245+
{{- end -}}
246+
{{- end -}}
247+
234248
{{/*
235249
imagePullPolicy: global.imagePullPolicy when set, IfNotPresent otherwise. One
236250
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
@@ -77,6 +77,7 @@ spec:
7777
metadata:
7878
labels:
7979
app: ate-api-server
80+
{{- with include "substrate.podLabels" $ }}{{- . | nindent 8 }}{{- end }}
8081
annotations:
8182
checksum/api-config: {{ .Values.ateApi.logLevel | sha256sum }}
8283
prometheus.io/scrape: "true"

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ spec:
7979
metadata:
8080
labels:
8181
app: ate-controller
82+
{{- with include "substrate.podLabels" $ }}{{- . | nindent 8 }}{{- end }}
8283
spec:
8384
serviceAccountName: {{ include "substrate.fullname" (list "ate-controller" .) }}
8485
{{- 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
@@ -126,6 +126,7 @@ spec:
126126
metadata:
127127
labels:
128128
app: atelet
129+
{{- with include "substrate.podLabels" $ }}{{- . | nindent 8 }}{{- end }}
129130
annotations:
130131
prometheus.io/scrape: "true"
131132
prometheus.io/port: "9090"

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ spec:
132132
metadata:
133133
labels:
134134
app: atenet-egress
135+
{{- with include "substrate.podLabels" $ }}{{- . | nindent 8 }}{{- end }}
135136
spec:
136137
serviceAccountName: {{ include "substrate.fullname" (list "atenet-egress" .) }}
137138
securityContext:

0 commit comments

Comments
 (0)