Skip to content

Commit 00bfb2e

Browse files
authored
Fix several Helm YAML issues with extraModules and extraInitContainers (#9709)
* Fix indention issue for DaemonSets when using extraModules and extraInitContainers * Improve documentation * Unify and fix templating * Enable support for the opentelemetry from values.yaml
1 parent 9b35992 commit 00bfb2e

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

charts/ingress-nginx/templates/controller-daemonset.yaml

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -178,17 +178,14 @@ spec:
178178
{{- end }}
179179
{{- if .Values.controller.extraModules }}
180180
{{- range .Values.controller.extraModules }}
181-
- name: {{ .Name }}
182-
image: {{ .Image }}
183-
command: ['sh', '-c', '/usr/local/bin/init_module.sh']
184-
{{- if (or $.Values.controller.containerSecurityContext .containerSecurityContext) }}
185-
securityContext: {{ .containerSecurityContext | default $.Values.controller.containerSecurityContext | toYaml | nindent 14 }}
186-
{{- end }}
187-
volumeMounts:
188-
- name: modules
189-
mountPath: /modules_mount
181+
{{ $containerSecurityContext := .containerSecurityContext | default $.Values.controller.containerSecurityContext }}
182+
{{ include "extraModules" (dict "name" .name "image" .image "containerSecurityContext" $containerSecurityContext) | indent 8 }}
190183
{{- end }}
191184
{{- end }}
185+
{{- if .Values.controller.opentelemetry.enabled}}
186+
{{ $otelContainerSecurityContext := $.Values.controller.opentelemetry.containerSecurityContext | default $.Values.controller.containerSecurityContext }}
187+
{{- include "extraModules" (dict "name" "opentelemetry" "image" .Values.controller.opentelemetry.image "containerSecurityContext" $otelContainerSecurityContext) | nindent 8}}
188+
{{- end}}
192189
{{- end }}
193190
{{- if .Values.controller.hostNetwork }}
194191
hostNetwork: {{ .Values.controller.hostNetwork }}
@@ -207,9 +204,9 @@ spec:
207204
{{- end }}
208205
serviceAccountName: {{ template "ingress-nginx.serviceAccountName" . }}
209206
terminationGracePeriodSeconds: {{ .Values.controller.terminationGracePeriodSeconds }}
210-
{{- if (or .Values.controller.customTemplate.configMapName .Values.controller.extraVolumeMounts .Values.controller.admissionWebhooks.enabled .Values.controller.extraVolumes .Values.controller.extraModules) }}
207+
{{- if (or .Values.controller.customTemplate.configMapName .Values.controller.extraVolumeMounts .Values.controller.admissionWebhooks.enabled .Values.controller.extraVolumes .Values.controller.extraModules .Values.controller.opentelemetry.enabled) }}
211208
volumes:
212-
{{- if .Values.controller.extraModules }}
209+
{{- if (or .Values.controller.extraModules .Values.controller.opentelemetry.enabled)}}
213210
- name: modules
214211
emptyDir: {}
215212
{{- end }}

charts/ingress-nginx/templates/controller-deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ spec:
185185
{{- if .Values.controller.extraModules }}
186186
{{- range .Values.controller.extraModules }}
187187
{{ $containerSecurityContext := .containerSecurityContext | default $.Values.controller.containerSecurityContext }}
188-
{{- include "extraModules" (dict "name" .name "image" .image "containerSecurityContext" $containerSecurityContext | nindent 8) }}
188+
{{ include "extraModules" (dict "name" .name "image" .image "containerSecurityContext" $containerSecurityContext) | indent 8 }}
189189
{{- end }}
190190
{{- end }}
191191
{{- if .Values.controller.opentelemetry.enabled}}

charts/ingress-nginx/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,8 @@ controller:
527527

528528
# -- Modules, which are mounted into the core nginx image. See values.yaml for a sample to add opentelemetry module
529529
extraModules: []
530+
# - name: mytestmodule
531+
# image: registry.k8s.io/ingress-nginx/mytestmodule
530532
# containerSecurityContext:
531533
# allowPrivilegeEscalation: false
532534
#

0 commit comments

Comments
 (0)