Skip to content

Commit d02c4a8

Browse files
pascalbreuningerpascal.breuninger (🤖)
andcommitted
fix(chart): quote .Release.Name in label values to prevent YAML int coercion
When the Helm release name is a purely numeric string (e.g. "1"), YAML parsers interpret unquoted label values as integers rather than strings. This causes yaml.UnmarshalStrict to fail with a type-mismatch error in the vCluster pod at startup. Add the `quote` pipeline function to all `release:` and `vcluster.loft.sh/managed-by:` label values that use .Release.Name directly as a standalone value in: - chart/templates/statefulset.yaml - chart/templates/service.yaml - chart/templates/networkpolicy.yaml - chart/templates/etcd-statefulset.yaml - chart/templates/etcd-service.yaml - chart/templates/pod-disruption-budget.yaml Resolves ENG-8736 Co-Authored-By: pascal.breuninger (🤖) <noreply@loft.sh>
1 parent 33a5a21 commit d02c4a8

File tree

6 files changed

+23
-23
lines changed

6 files changed

+23
-23
lines changed

chart/templates/etcd-service.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ spec:
2828
protocol: TCP
2929
selector:
3030
app: vcluster-etcd
31-
release: {{ .Release.Name }}
31+
release: {{ .Release.Name | quote }}
3232
{{- end }}
3333
{{- end }}

chart/templates/etcd-statefulset.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ spec:
3232
selector:
3333
matchLabels:
3434
app: vcluster-etcd
35-
release: {{ .Release.Name }}
35+
release: {{ .Release.Name | quote }}
3636
{{- if $externalEtcd.persistence.volumeClaimTemplates }}
3737
volumeClaimTemplates:
3838
{{ toYaml $externalEtcd.persistence.volumeClaimTemplates | indent 4 }}
@@ -57,7 +57,7 @@ spec:
5757
{{- end }}
5858
labels:
5959
app: vcluster-etcd
60-
release: {{ .Release.Name }}
60+
release: {{ .Release.Name | quote }}
6161
{{- range $k, $v := $externalEtcd.pods.labels }}
6262
{{ $k }}: {{ $v | quote }}
6363
{{- end }}
@@ -82,7 +82,7 @@ spec:
8282
- key: release
8383
operator: In
8484
values:
85-
- {{ .Release.Name }}
85+
- {{ .Release.Name | quote }}
8686
topologyKey: "kubernetes.io/hostname"
8787
# if possible avoid scheduling pod onto node that is in the same zone as one or more vcluster pods are running
8888
- weight: 50
@@ -96,7 +96,7 @@ spec:
9696
- key: release
9797
operator: In
9898
values:
99-
- {{ .Release.Name }}
99+
- {{ .Release.Name | quote }}
100100
topologyKey: topology.kubernetes.io/zone
101101
{{- end }}
102102
{{- if $externalEtcd.scheduling.topologySpreadConstraints }}

chart/templates/networkpolicy.yaml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ metadata:
1616
spec:
1717
podSelector:
1818
matchLabels:
19-
vcluster.loft.sh/managed-by: {{ .Release.Name }}
19+
vcluster.loft.sh/managed-by: {{ .Release.Name | quote }}
2020
policyTypes:
2121
- Egress
2222
- Ingress
@@ -32,13 +32,13 @@ spec:
3232
to:
3333
- podSelector:
3434
matchLabels:
35-
release: {{ .Release.Name }}
35+
release: {{ .Release.Name | quote }}
3636

3737
# Allow egress to other vcluster workloads, including coredns when not embedded.
3838
- to:
3939
- podSelector:
4040
matchLabels:
41-
vcluster.loft.sh/managed-by: {{ .Release.Name }}
41+
vcluster.loft.sh/managed-by: {{ .Release.Name | quote }}
4242

4343
{{- if .Values.policies.networkPolicy.workload.publicEgress.enabled }}
4444
# Allow public egress.
@@ -57,13 +57,13 @@ spec:
5757
- from:
5858
- podSelector:
5959
matchLabels:
60-
release: {{ .Release.Name }}
60+
release: {{ .Release.Name | quote }}
6161

6262
# Allow ingress from other vcluster workloads.
6363
- from:
6464
- podSelector:
6565
matchLabels:
66-
vcluster.loft.sh/managed-by: {{ .Release.Name }}
66+
vcluster.loft.sh/managed-by: {{ .Release.Name | quote }}
6767

6868
{{- if .Values.policies.networkPolicy.workload.ingress }}
6969
{{ toYaml .Values.policies.networkPolicy.workload.ingress | indent 4 }}
@@ -79,7 +79,7 @@ metadata:
7979
spec:
8080
podSelector:
8181
matchLabels:
82-
release: {{ .Release.Name }}
82+
release: {{ .Release.Name | quote }}
8383
policyTypes:
8484
- Egress
8585
- Ingress
@@ -106,13 +106,13 @@ spec:
106106
- to:
107107
- podSelector:
108108
matchLabels:
109-
release: {{ .Release.Name }}
109+
release: {{ .Release.Name | quote }}
110110

111111
# Allow egress connections to vcluster workloads.
112112
- to:
113113
- podSelector:
114114
matchLabels:
115-
vcluster.loft.sh/managed-by: {{ .Release.Name }}
115+
vcluster.loft.sh/managed-by: {{ .Release.Name | quote }}
116116

117117
# Allow egress to vcluster platform.
118118
- to:
@@ -130,7 +130,7 @@ spec:
130130
- from:
131131
- podSelector:
132132
matchLabels:
133-
release: {{ .Release.Name }}
133+
release: {{ .Release.Name | quote }}
134134

135135
# Allow ingress for vcluster workloads.
136136
- ports:
@@ -143,7 +143,7 @@ spec:
143143
from:
144144
- podSelector:
145145
matchLabels:
146-
vcluster.loft.sh/managed-by: {{ .Release.Name }}
146+
vcluster.loft.sh/managed-by: {{ .Release.Name | quote }}
147147

148148
# Allow ingress from vcluster snapshot.
149149
- from:
@@ -174,7 +174,7 @@ spec:
174174
podSelector:
175175
matchLabels:
176176
k8s-app: vcluster-kube-dns
177-
vcluster.loft.sh/managed-by: {{ .Release.Name }}
177+
vcluster.loft.sh/managed-by: {{ .Release.Name | quote }}
178178
policyTypes:
179179
- Egress
180180
- Ingress
@@ -195,7 +195,7 @@ spec:
195195
to:
196196
- podSelector:
197197
matchLabels:
198-
release: {{ .Release.Name }}
198+
release: {{ .Release.Name | quote }}
199199

200200
ingress:
201201
# Allow ingress from vcluster workloads.
@@ -207,7 +207,7 @@ spec:
207207
from:
208208
- podSelector:
209209
matchLabels:
210-
vcluster.loft.sh/managed-by: {{ .Release.Name }}
210+
vcluster.loft.sh/managed-by: {{ .Release.Name | quote }}
211211
{{- end }}
212212

213213
---
@@ -229,7 +229,7 @@ spec:
229229
- to:
230230
- podSelector:
231231
matchLabels:
232-
release: {{ .Release.Name }}
232+
release: {{ .Release.Name | quote }}
233233

234234
# Allow egress to host kube-dns.
235235
- to:

chart/templates/pod-disruption-budget.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ spec:
1717
selector:
1818
matchLabels:
1919
app: vcluster
20-
release: {{ .Release.Name }}
20+
release: {{ .Release.Name | quote }}
2121
{{- end }}

chart/templates/service.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,6 @@ spec:
4747
{{- if not .Values.controlPlane.service.spec.selector }}
4848
selector:
4949
app: vcluster
50-
release: {{ .Release.Name }}
50+
release: {{ .Release.Name | quote }}
5151
{{- end }}
5252
{{- end }}

chart/templates/statefulset.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ metadata:
77
labels:
88
app: vcluster
99
chart: "{{ include "vcluster.version.label" $ }}"
10-
release: {{ .Release.Name }}
10+
release: {{ .Release.Name | quote }}
1111
heritage: "{{ .Release.Service }}"
1212
{{- if .Values.controlPlane.statefulSet.labels }}
1313
{{ toYaml .Values.controlPlane.statefulSet.labels | indent 4 }}
@@ -51,7 +51,7 @@ spec:
5151
{{- end }}
5252
labels:
5353
app: vcluster
54-
release: {{ .Release.Name }}
54+
release: {{ .Release.Name | quote }}
5555
{{- if .Values.controlPlane.statefulSet.pods.labels }}
5656
{{ toYaml .Values.controlPlane.statefulSet.pods.labels | indent 8 }}
5757
{{- end }}

0 commit comments

Comments
 (0)