Skip to content

Commit a609690

Browse files
authored
fix(helm): avoid null volumes in deployment (#608)
Description of changes: The AWS ACK Helm chart generates `"volumes": null` when no static secret `.Values.aws.credentials.secretName` or no extra volume `.Values.deployment.extraVolumes` was set. This can cause issues during the deployment, particularly with admission controllers such as policy engines. An example issue can be found here kyverno/policies#1310 by Kyverno. This PR solves such problems without using a workaround, like deploying an unused emptyDir. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent c680829 commit a609690

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

templates/helm/templates/deployment.yaml.tpl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ spec:
148148
{{ "{{- if .Values.deployment.extraEnvVars -}}" }}
149149
{{ "{{ toYaml .Values.deployment.extraEnvVars | nindent 8 }}" }}
150150
{{ "{{- end }}" }}
151+
{{ "{{- if or .Values.aws.credentials.secretName .Values.deployment.extraVolumeMounts }}" }}
151152
volumeMounts:
152153
{{ "{{- if .Values.aws.credentials.secretName }}" }}
153154
- name: {{ "{{ .Values.aws.credentials.secretName }}" }}
@@ -157,6 +158,7 @@ spec:
157158
{{ "{{- if .Values.deployment.extraVolumeMounts -}}" }}
158159
{{ "{{ toYaml .Values.deployment.extraVolumeMounts | nindent 10 }}" }}
159160
{{ "{{- end }}" }}
161+
{{ "{{- end }}" }}
160162
securityContext:
161163
allowPrivilegeEscalation: false
162164
privileged: false
@@ -195,15 +197,17 @@ spec:
195197
hostPID: false
196198
hostNetwork: {{ "{{ .Values.deployment.hostNetwork }}" }}
197199
dnsPolicy: {{ "{{ .Values.deployment.dnsPolicy }}" }}
200+
{{ "{{- if or .Values.aws.credentials.secretName .Values.deployment.extraVolumes }}" }}
198201
volumes:
199202
{{ "{{- if .Values.aws.credentials.secretName }}" }}
200203
- name: {{ "{{ .Values.aws.credentials.secretName }}" }}
201204
secret:
202205
secretName: {{ "{{ .Values.aws.credentials.secretName }}" }}
203206
{{ "{{- end }}" }}
204-
{{ "{{- if .Values.deployment.extraVolumes }}" }}
205-
{{ "{{ toYaml .Values.deployment.extraVolumes | indent 8}}" }}
206-
{{ "{{- end }}" }}
207+
{{ "{{- if .Values.deployment.extraVolumes }}" }}
208+
{{ "{{ toYaml .Values.deployment.extraVolumes | indent 8 }}" }}
209+
{{ "{{- end }}" }}
210+
{{ "{{- end }}" }}
207211
{{ " {{- with .Values.deployment.strategy }}" }}
208212
strategy: {{ "{{- toYaml . | nindent 4 }}" }}
209213
{{ " {{- end }}" }}

0 commit comments

Comments
 (0)