Skip to content

Commit 27e465c

Browse files
committed
fix: strip enabled key from securityContext before rendering
The podSecurityContext, securityContext, and metrics exporter securityContext values support an 'enabled' field as a helm-level toggle. However, this field is not a valid Kubernetes PodSecurityContext or SecurityContext field. When rendered verbatim, Kubernetes silently strips it, causing GitOps tools like ArgoCD and Rancher Fleet to report resources as perpetually out-of-sync. Use omit to strip the 'enabled' key before piping to toYaml in both deploy_valkey.yaml and statefulset.yaml templates. Fixes: #139 Signed-off-by: Darpa Sehgal <6688157+DarpaSehgal@users.noreply.github.com>
1 parent c179c97 commit 27e465c

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

valkey/templates/deploy_valkey.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ spec:
4646
priorityClassName: {{ .Values.priorityClassName | quote }}
4747
{{- end }}
4848
securityContext:
49-
{{- toYaml .Values.podSecurityContext | nindent 8 }}
49+
{{- omit .Values.podSecurityContext "enabled" | toYaml | nindent 8 }}
5050
initContainers:
5151
- name: {{ include "valkey.fullname" . }}-init
5252
image: {{ include "valkey.image" . }}
5353
imagePullPolicy: {{ .Values.image.pullPolicy }}
5454
{{- with .Values.securityContext }}
5555
securityContext:
56-
{{- toYaml . | nindent 12 }}
56+
{{- omit . "enabled" | toYaml | nindent 12 }}
5757
{{- end }}
5858
command: [ "/scripts/init.sh" ]
5959
volumeMounts:
@@ -104,7 +104,7 @@ spec:
104104
command: [ "valkey-server" ]
105105
args: [ "/data/conf/valkey.conf" ]
106106
securityContext:
107-
{{- toYaml .Values.securityContext | nindent 12 }}
107+
{{- omit .Values.securityContext "enabled" | toYaml | nindent 12 }}
108108
env:
109109
{{- range $key, $val := .Values.env }}
110110
- name: {{ $key }}
@@ -163,7 +163,7 @@ spec:
163163
imagePullPolicy: {{ .Values.metrics.exporter.image.pullPolicy | quote }}
164164
{{- with .Values.metrics.exporter.securityContext }}
165165
securityContext:
166-
{{- toYaml . | nindent 12 }}
166+
{{- omit . "enabled" | toYaml | nindent 12 }}
167167
{{- end }}
168168
{{- with .Values.metrics.exporter.command }}
169169
command:

valkey/templates/statefulset.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,14 @@ spec:
6060
priorityClassName: {{ .Values.priorityClassName | quote }}
6161
{{- end }}
6262
securityContext:
63-
{{- toYaml .Values.podSecurityContext | nindent 8 }}
63+
{{- omit .Values.podSecurityContext "enabled" | toYaml | nindent 8 }}
6464
initContainers:
6565
- name: {{ include "valkey.fullname" . }}-init
6666
image: {{ include "valkey.image" . }}
6767
imagePullPolicy: {{ .Values.image.pullPolicy }}
6868
{{- with .Values.securityContext }}
6969
securityContext:
70-
{{- toYaml . | nindent 12 }}
70+
{{- omit . "enabled" | toYaml | nindent 12 }}
7171
{{- end }}
7272
command: [ "/scripts/init.sh" ]
7373
env:
@@ -117,7 +117,7 @@ spec:
117117
command: [ "valkey-server" ]
118118
args: [ "/data/conf/valkey.conf" ]
119119
securityContext:
120-
{{- toYaml .Values.securityContext | nindent 12 }}
120+
{{- omit .Values.securityContext "enabled" | toYaml | nindent 12 }}
121121
env:
122122
- name: POD_INDEX
123123
valueFrom:
@@ -177,7 +177,7 @@ spec:
177177
imagePullPolicy: {{ .Values.metrics.exporter.image.pullPolicy | quote }}
178178
{{- with .Values.metrics.exporter.securityContext }}
179179
securityContext:
180-
{{- toYaml . | nindent 12 }}
180+
{{- omit . "enabled" | toYaml | nindent 12 }}
181181
{{- end }}
182182
{{- with .Values.metrics.exporter.command }}
183183
command:

0 commit comments

Comments
 (0)