Skip to content

Commit 5758b4f

Browse files
Cloudsky01alepane21StarpTechpepol
authored
fix(helm): exclude commonLabels from immutable selector matchLabels (#2571)
Co-authored-by: Alessandro Pagnin <ale@wundergraph.com> Co-authored-by: Dustin Deus <deusdustin@gmail.com> Co-authored-by: Peter Polacik <peter@wundergraph.com>
1 parent 6b118ec commit 5758b4f

File tree

12 files changed

+78
-18
lines changed

12 files changed

+78
-18
lines changed

helm/cosmo/charts/cdn/templates/_helpers.tpl

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,24 +45,31 @@ Create chart name and version as used by the chart label.
4545

4646
{{/*
4747
Common labels
48+
Includes standard Kubernetes recommended labels, selector labels,
49+
and user-defined commonLabels. Note: commonLabels are rendered here
50+
(not in selectorLabels) to avoid adding mutable labels to immutable
51+
selector matchLabels.
4852
*/}}
4953
{{- define "cdn.labels" -}}
5054
{{ $version := .Values.image.version | default .Chart.AppVersion -}}
5155
helm.sh/chart: {{ include "cdn.chart" . }}
5256
{{ include "cdn.selectorLabels" . }}
5357
app.kubernetes.io/version: {{ $version | quote }}
5458
app.kubernetes.io/managed-by: {{ .Release.Service }}
59+
{{- range $key, $value := .Values.commonLabels }}
60+
{{ $key }}: {{ quote $value }}
61+
{{- end }}
5562
{{- end }}
5663

5764
{{/*
5865
Selector labels
66+
Used in spec.selector.matchLabels which are immutable after creation.
67+
Only include stable, deterministic labels here -- do not add commonLabels
68+
or other user-configurable values.
5969
*/}}
6070
{{- define "cdn.selectorLabels" -}}
6171
app.kubernetes.io/name: {{ include "cdn.name" . }}
6272
app.kubernetes.io/instance: {{ .Release.Name }}
63-
{{- range $key, $value := .Values.commonLabels }}
64-
{{ $key }}: {{ quote $value }}
65-
{{- end }}
6673
{{- end }}
6774

6875
{{/*

helm/cosmo/charts/cdn/templates/deployment.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ spec:
3333
{{- end }}
3434
labels:
3535
{{- include "cdn.selectorLabels" . | nindent 8 }}
36+
{{- range $key, $value := .Values.commonLabels }}
37+
{{ $key }}: {{ quote $value }}
38+
{{- end }}
3639
spec:
3740
{{- with .Values.imagePullSecrets }}
3841
imagePullSecrets:

helm/cosmo/charts/controlplane/templates/_helpers.tpl

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,20 @@ Create chart name and version as used by the chart label.
4545

4646
{{/*
4747
Common labels
48+
Includes standard Kubernetes recommended labels, selector labels,
49+
and user-defined commonLabels. Note: commonLabels are rendered here
50+
(not in selectorLabels) to avoid adding mutable labels to immutable
51+
selector matchLabels.
4852
*/}}
4953
{{- define "controlplane.labels" -}}
5054
{{ $version := .Values.image.version | default .Chart.AppVersion -}}
5155
helm.sh/chart: {{ include "controlplane.chart" . }}
5256
{{ include "controlplane.selectorLabels" . }}
5357
app.kubernetes.io/version: {{ $version | quote }}
5458
app.kubernetes.io/managed-by: {{ .Release.Service }}
59+
{{- range $key, $value := .Values.commonLabels }}
60+
{{ $key }}: {{ quote $value }}
61+
{{- end }}
5562
{{- end }}
5663

5764
{{/*
@@ -72,13 +79,13 @@ extra labels (jobLabels) to each job
7279

7380
{{/*
7481
Selector labels
82+
Used in spec.selector.matchLabels which are immutable after creation.
83+
Only include stable, deterministic labels here -- do not add commonLabels
84+
or other user-configurable values.
7585
*/}}
7686
{{- define "controlplane.selectorLabels" -}}
7787
app.kubernetes.io/name: {{ include "controlplane.name" . }}
7888
app.kubernetes.io/instance: {{ .Release.Name }}
79-
{{- range $key, $value := .Values.commonLabels }}
80-
{{ $key }}: {{ quote $value }}
81-
{{- end }}
8289
{{- end }}
8390

8491
{{/*

helm/cosmo/charts/controlplane/templates/deployment.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ spec:
4444
{{- end }}
4545
labels:
4646
{{- include "controlplane.selectorLabels" . | nindent 8 }}
47+
{{- range $key, $value := .Values.commonLabels }}
48+
{{ $key }}: {{ quote $value }}
49+
{{- end }}
4750
spec:
4851
{{- with .Values.imagePullSecrets }}
4952
imagePullSecrets:

helm/cosmo/charts/graphqlmetrics/templates/_helpers.tpl

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,24 +45,31 @@ Create chart name and version as used by the chart label.
4545

4646
{{/*
4747
Common labels
48+
Includes standard Kubernetes recommended labels, selector labels,
49+
and user-defined commonLabels. Note: commonLabels are rendered here
50+
(not in selectorLabels) to avoid adding mutable labels to immutable
51+
selector matchLabels.
4852
*/}}
4953
{{- define "graphqlmetrics.labels" -}}
5054
{{ $version := .Values.image.version | default .Chart.AppVersion -}}
5155
helm.sh/chart: {{ include "graphqlmetrics.chart" . }}
5256
{{ include "graphqlmetrics.selectorLabels" . }}
5357
app.kubernetes.io/version: {{ $version | quote }}
5458
app.kubernetes.io/managed-by: {{ .Release.Service }}
59+
{{- range $key, $value := .Values.commonLabels }}
60+
{{ $key }}: {{ quote $value }}
61+
{{- end }}
5562
{{- end }}
5663

5764
{{/*
5865
Selector labels
66+
Used in spec.selector.matchLabels which are immutable after creation.
67+
Only include stable, deterministic labels here -- do not add commonLabels
68+
or other user-configurable values.
5969
*/}}
6070
{{- define "graphqlmetrics.selectorLabels" -}}
6171
app.kubernetes.io/name: {{ include "graphqlmetrics.name" . }}
6272
app.kubernetes.io/instance: {{ .Release.Name }}
63-
{{- range $key, $value := .Values.commonLabels }}
64-
{{ $key }}: {{ quote $value }}
65-
{{- end }}
6673
{{- end }}
6774

6875
{{/*

helm/cosmo/charts/graphqlmetrics/templates/deployment.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ spec:
3232
{{- end }}
3333
labels:
3434
{{- include "graphqlmetrics.selectorLabels" . | nindent 8 }}
35+
{{- range $key, $value := .Values.commonLabels }}
36+
{{ $key }}: {{ quote $value }}
37+
{{- end }}
3538
spec:
3639
{{- with .Values.imagePullSecrets }}
3740
imagePullSecrets:

helm/cosmo/charts/otelcollector/templates/_helpers.tpl

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,24 +45,31 @@ Create chart name and version as used by the chart label.
4545

4646
{{/*
4747
Common labels
48+
Includes standard Kubernetes recommended labels, selector labels,
49+
and user-defined commonLabels. Note: commonLabels are rendered here
50+
(not in selectorLabels) to avoid adding mutable labels to immutable
51+
selector matchLabels.
4852
*/}}
4953
{{- define "otelcollector.labels" -}}
5054
{{ $version := .Values.image.version | default .Chart.AppVersion -}}
5155
helm.sh/chart: {{ include "otelcollector.chart" . }}
5256
{{ include "otelcollector.selectorLabels" . }}
5357
app.kubernetes.io/version: {{ $version | quote }}
5458
app.kubernetes.io/managed-by: {{ .Release.Service }}
59+
{{- range $key, $value := .Values.commonLabels }}
60+
{{ $key }}: {{ quote $value }}
61+
{{- end }}
5562
{{- end }}
5663

5764
{{/*
5865
Selector labels
66+
Used in spec.selector.matchLabels which are immutable after creation.
67+
Only include stable, deterministic labels here -- do not add commonLabels
68+
or other user-configurable values.
5969
*/}}
6070
{{- define "otelcollector.selectorLabels" -}}
6171
app.kubernetes.io/name: {{ include "otelcollector.name" . }}
6272
app.kubernetes.io/instance: {{ .Release.Name }}
63-
{{- range $key, $value := .Values.commonLabels }}
64-
{{ $key }}: {{ quote $value }}
65-
{{- end }}
6673
{{- end }}
6774

6875
{{/*

helm/cosmo/charts/otelcollector/templates/deployment.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ spec:
3232
{{- end }}
3333
labels:
3434
{{- include "otelcollector.selectorLabels" . | nindent 8 }}
35+
{{- range $key, $value := .Values.commonLabels }}
36+
{{ $key }}: {{ quote $value }}
37+
{{- end }}
3538
spec:
3639
{{- with .Values.imagePullSecrets }}
3740
imagePullSecrets:

helm/cosmo/charts/router/templates/_helpers.tpl

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,24 +63,31 @@ Additional Pod Labels that are just rendered in metadata.labels
6363

6464
{{/*
6565
Common labels
66+
Includes standard Kubernetes recommended labels, selector labels,
67+
and user-defined commonLabels. Note: commonLabels are rendered here
68+
(not in selectorLabels) to avoid adding mutable labels to immutable
69+
selector matchLabels.
6670
*/}}
6771
{{- define "router.labels" -}}
6872
{{ $version := .Values.image.version | default .Chart.AppVersion | replace ":" "_" | trunc 63 -}}
6973
helm.sh/chart: {{ include "router.chart" . }}
7074
{{ include "router.selectorLabels" . }}
7175
app.kubernetes.io/version: {{ $version | quote }}
7276
app.kubernetes.io/managed-by: {{ .Release.Service }}
77+
{{- range $key, $value := .Values.commonLabels }}
78+
{{ $key }}: {{ quote $value }}
79+
{{- end }}
7380
{{- end }}
7481

7582
{{/*
7683
Selector labels
84+
Used in spec.selector.matchLabels which are immutable after creation.
85+
Only include stable, deterministic labels here -- do not add commonLabels
86+
or other user-configurable values.
7787
*/}}
7888
{{- define "router.selectorLabels" -}}
7989
app.kubernetes.io/name: {{ include "router.name" . }}
8090
app.kubernetes.io/instance: {{ .Release.Name }}
81-
{{- range $key, $value := .Values.commonLabels }}
82-
{{ $key }}: {{ quote $value }}
83-
{{- end }}
8491
{{- end }}
8592

8693
{{/*

helm/cosmo/charts/router/templates/deployment.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ spec:
3131
labels:
3232
{{- include "router.selectorLabels" . | nindent 8 }}
3333
{{- include "router.additionalPodLabels" . | nindent 8 }}
34+
{{- range $key, $value := .Values.commonLabels }}
35+
{{ $key }}: {{ quote $value }}
36+
{{- end }}
3437
spec:
3538
{{- with .Values.imagePullSecrets }}
3639
imagePullSecrets:

0 commit comments

Comments
 (0)