Skip to content

Commit 6f03eb1

Browse files
authored
fix(chart): accessing .Values in templates (#2174)
Right now browser nodes do not start because startup probe does not work because probe scripts are not mounted to the pod because ".Values.nodeConfigMap.extraScripts" is empty when template is called with non-global context.
1 parent db91598 commit 6f03eb1

File tree

1 file changed

+35
-35
lines changed

1 file changed

+35
-35
lines changed

Diff for: charts/selenium-grid/templates/_helpers.tpl

+35-35
Original file line numberDiff line numberDiff line change
@@ -133,23 +133,23 @@ Common autoscaling spec template
133133
{{- define "seleniumGrid.autoscalingTemplate" -}}
134134
{{- $spec := toYaml (dict) -}}
135135
{{/* Merge with precedence from right to left */}}
136-
{{- with .Values.autoscaling.scaledOptions -}}
136+
{{- with $.Values.autoscaling.scaledOptions -}}
137137
{{- $spec = mergeOverwrite ($spec | fromYaml) . | toYaml -}}
138138
{{- end -}}
139139
{{- with .node.scaledOptions -}}
140140
{{- $spec = mergeOverwrite ($spec | fromYaml) . | toYaml -}}
141141
{{- end -}}
142-
{{- if eq .Values.autoscaling.scalingType "deployment" -}}
143-
{{- with .Values.autoscaling.scaledObjectOptions -}}
142+
{{- if eq $.Values.autoscaling.scalingType "deployment" -}}
143+
{{- with $.Values.autoscaling.scaledObjectOptions -}}
144144
{{- $spec = mergeOverwrite ($spec | fromYaml) . | toYaml -}}
145145
{{- end -}}
146146
{{- with .node.scaledObjectOptions -}}
147147
{{- $spec = mergeOverwrite ($spec | fromYaml) . | toYaml -}}
148148
{{- end -}}
149149
{{- $advanced := (dict "scaleTargetRef" (dict "name" .name) "advanced" (dict "horizontalPodAutoscalerConfig" (dict "name" .name) "restoreToOriginalReplicaCount" true)) -}}
150150
{{- $spec = mergeOverwrite ($spec | fromYaml) $advanced | toYaml -}}
151-
{{- else if eq .Values.autoscaling.scalingType "job" -}}
152-
{{- with .Values.autoscaling.scaledJobOptions -}}
151+
{{- else if eq $.Values.autoscaling.scalingType "job" -}}
152+
{{- with $.Values.autoscaling.scaledJobOptions -}}
153153
{{- $spec = mergeOverwrite ($spec | fromYaml) . | toYaml -}}
154154
{{- end -}}
155155
{{- with .node.scaledJobOptions -}}
@@ -160,7 +160,7 @@ Common autoscaling spec template
160160
{{- if and $spec (ne $spec "{}") -}}
161161
{{ tpl $spec $ }}
162162
{{- end -}}
163-
{{- if not .Values.autoscaling.scaledOptions.triggers }}
163+
{{- if not $.Values.autoscaling.scaledOptions.triggers }}
164164
triggers:
165165
- type: selenium-grid
166166
metadata:
@@ -184,7 +184,7 @@ template:
184184
{{- with .node.labels }}
185185
{{- toYaml . | nindent 6 }}
186186
{{- end }}
187-
{{- with .Values.customLabels }}
187+
{{- with $.Values.customLabels }}
188188
{{- toYaml . | nindent 6 }}
189189
{{- end }}
190190
annotations:
@@ -208,8 +208,8 @@ template:
208208
{{- end }}
209209
containers:
210210
- name: {{ .name }}
211-
{{- $imageTag := default .Values.global.seleniumGrid.nodesImageTag .node.imageTag }}
212-
{{- $imageRegistry := default .Values.global.seleniumGrid.imageRegistry .node.imageRegistry }}
211+
{{- $imageTag := default $.Values.global.seleniumGrid.nodesImageTag .node.imageTag }}
212+
{{- $imageRegistry := default $.Values.global.seleniumGrid.imageRegistry .node.imageRegistry }}
213213
image: {{ printf "%s/%s:%s" $imageRegistry .node.imageName $imageTag }}
214214
imagePullPolicy: {{ .node.imagePullPolicy }}
215215
env:
@@ -259,14 +259,14 @@ template:
259259
volumeMounts:
260260
- name: dshm
261261
mountPath: /dev/shm
262-
{{- range $fileName, $value := .Values.nodeConfigMap.extraScripts }}
262+
{{- range $fileName, $value := $.Values.nodeConfigMap.extraScripts }}
263263
- name: {{ tpl (default (include "seleniumGrid.node.configmap.fullname" $) $.Values.nodeConfigMap.scriptVolumeMountName) $ }}
264264
mountPath: {{ $.Values.nodeConfigMap.extraScriptsDirectory }}/{{ $fileName }}
265265
subPath: {{ $fileName }}
266266
{{- end }}
267-
{{- if .Values.tls.enabled }}
267+
{{- if $.Values.tls.enabled }}
268268
- name: {{ include "seleniumGrid.tls.fullname" $ | quote }}
269-
mountPath: {{ .Values.serverConfigMap.certVolumeMountPath }}
269+
mountPath: {{ $.Values.serverConfigMap.certVolumeMountPath }}
270270
readOnly: true
271271
{{- end }}
272272
{{- if .node.extraVolumeMounts }}
@@ -336,20 +336,20 @@ template:
336336
{{- if .node.sidecars }}
337337
{{- toYaml .node.sidecars | nindent 6 }}
338338
{{- end }}
339-
{{- if .Values.videoRecorder.enabled }}
339+
{{- if $.Values.videoRecorder.enabled }}
340340
- name: video
341-
{{- $imageTag := default .Values.global.seleniumGrid.videoImageTag .Values.videoRecorder.imageTag }}
342-
{{- $imageRegistry := default .Values.global.seleniumGrid.imageRegistry .Values.videoRecorder.imageRegistry }}
343-
image: {{ printf "%s/%s:%s" $imageRegistry .Values.videoRecorder.imageName $imageTag }}
344-
imagePullPolicy: {{ .Values.videoRecorder.imagePullPolicy }}
341+
{{- $imageTag := default $.Values.global.seleniumGrid.videoImageTag $.Values.videoRecorder.imageTag }}
342+
{{- $imageRegistry := default $.Values.global.seleniumGrid.imageRegistry $.Values.videoRecorder.imageRegistry }}
343+
image: {{ printf "%s/%s:%s" $imageRegistry $.Values.videoRecorder.imageName $imageTag }}
344+
imagePullPolicy: {{ $.Values.videoRecorder.imagePullPolicy }}
345345
env:
346346
- name: SE_NODE_PORT
347347
value: {{ .node.port | quote }}
348348
- name: DISPLAY_CONTAINER_NAME
349349
valueFrom:
350350
fieldRef:
351351
fieldPath: status.podIP
352-
{{- with .Values.videoRecorder.extraEnvironmentVariables }}
352+
{{- with $.Values.videoRecorder.extraEnvironmentVariables }}
353353
{{- tpl (toYaml .) $ | nindent 8 }}
354354
{{- end }}
355355
envFrom:
@@ -361,16 +361,16 @@ template:
361361
name: {{ template "seleniumGrid.recorder.configmap.fullname" $ }}
362362
- configMapRef:
363363
name: {{ template "seleniumGrid.server.configmap.fullname" $ }}
364-
{{- if and .Values.videoRecorder.uploader.enabled (not .Values.videoRecorder.uploader.name) }}
364+
{{- if and $.Values.videoRecorder.uploader.enabled (not $.Values.videoRecorder.uploader.name) }}
365365
- secretRef:
366-
name: {{ tpl (default (include "seleniumGrid.common.secrets.fullname" $) .Values.uploaderConfigMap.secretVolumeMountName) $ }}
366+
name: {{ tpl (default (include "seleniumGrid.common.secrets.fullname" $) $.Values.uploaderConfigMap.secretVolumeMountName) $ }}
367367
{{- end }}
368-
{{- with .Values.videoRecorder.extraEnvFrom }}
368+
{{- with $.Values.videoRecorder.extraEnvFrom }}
369369
{{- tpl (toYaml .) $ | nindent 8 }}
370370
{{- end }}
371-
{{- if gt (len .Values.videoRecorder.ports) 0 }}
371+
{{- if gt (len $.Values.videoRecorder.ports) 0 }}
372372
ports:
373-
{{- range .Values.videoRecorder.ports }}
373+
{{- range $.Values.videoRecorder.ports }}
374374
- containerPort: {{ . }}
375375
protocol: TCP
376376
{{- end }}
@@ -379,22 +379,22 @@ template:
379379
- name: dshm
380380
mountPath: /dev/shm
381381
{{- tpl (include "seleniumGrid.video.volumeMounts" .) $ | nindent 8 }}
382-
{{- with .Values.videoRecorder.resources }}
382+
{{- with $.Values.videoRecorder.resources }}
383383
resources: {{- toYaml . | nindent 10 }}
384384
{{- end }}
385-
{{- with .Values.videoRecorder.securityContext }}
385+
{{- with $.Values.videoRecorder.securityContext }}
386386
securityContext: {{- toYaml . | nindent 10 }}
387387
{{- end }}
388-
{{- with .Values.videoRecorder.startupProbe }}
388+
{{- with $.Values.videoRecorder.startupProbe }}
389389
startupProbe: {{- toYaml . | nindent 10 }}
390390
{{- end }}
391-
{{- with .Values.videoRecorder.livenessProbe }}
391+
{{- with $.Values.videoRecorder.livenessProbe }}
392392
livenessProbe: {{- toYaml . | nindent 10 }}
393393
{{- end }}
394-
{{- with .Values.videoRecorder.lifecycle }}
394+
{{- with $.Values.videoRecorder.lifecycle }}
395395
lifecycle: {{- toYaml . | nindent 10 }}
396396
{{- end }}
397-
{{- if and .Values.videoRecorder.uploader.enabled (not (empty .Values.videoRecorder.uploader.name)) }}
397+
{{- if and $.Values.videoRecorder.uploader.enabled (not (empty $.Values.videoRecorder.uploader.name)) }}
398398
- name: uploader
399399
{{- $imageTag := .uploader.imageTag }}
400400
{{- $imageRegistry := .uploader.imageRegistry }}
@@ -417,7 +417,7 @@ template:
417417
- configMapRef:
418418
name: {{ template "seleniumGrid.uploader.configmap.fullname" $ }}
419419
- secretRef:
420-
name: {{ tpl (default (include "seleniumGrid.common.secrets.fullname" $) .Values.uploaderConfigMap.secretVolumeMountName) $ }}
420+
name: {{ tpl (default (include "seleniumGrid.common.secrets.fullname" $) $.Values.uploaderConfigMap.secretVolumeMountName) $ }}
421421
{{- with .uploader.extraEnvFrom }}
422422
{{- tpl (toYaml .) $ | nindent 10 }}
423423
{{- end }}
@@ -431,9 +431,9 @@ template:
431431
{{- end }}
432432
{{- end }}
433433
{{- end }}
434-
{{- if or .Values.global.seleniumGrid.imagePullSecret .node.imagePullSecret }}
434+
{{- if or $.Values.global.seleniumGrid.imagePullSecret .node.imagePullSecret }}
435435
imagePullSecrets:
436-
- name: {{ default .Values.global.seleniumGrid.imagePullSecret .node.imagePullSecret }}
436+
- name: {{ default $.Values.global.seleniumGrid.imagePullSecret .node.imagePullSecret }}
437437
{{- end }}
438438
{{- with .node.nodeSelector }}
439439
nodeSelector: {{- toYaml . | nindent 6 }}
@@ -453,20 +453,20 @@ template:
453453
- name: {{ tpl (default (include "seleniumGrid.node.configmap.fullname" $) $.Values.nodeConfigMap.scriptVolumeMountName) $ }}
454454
configMap:
455455
name: {{ template "seleniumGrid.node.configmap.fullname" $ }}
456-
defaultMode: {{ .Values.nodeConfigMap.defaultMode }}
456+
defaultMode: {{ $.Values.nodeConfigMap.defaultMode }}
457457
- name: dshm
458458
emptyDir:
459459
medium: Memory
460460
sizeLimit: {{ default "1Gi" .node.dshmVolumeSizeLimit }}
461-
{{- if .Values.tls.enabled }}
461+
{{- if $.Values.tls.enabled }}
462462
- name: {{ include "seleniumGrid.tls.fullname" $ | quote }}
463463
secret:
464464
secretName: {{ include "seleniumGrid.tls.fullname" $ | quote }}
465465
{{- end }}
466466
{{- if .node.extraVolumes }}
467467
{{ tpl (toYaml .node.extraVolumes) $ | nindent 6 }}
468468
{{- end }}
469-
{{- if .Values.videoRecorder.enabled }}
469+
{{- if $.Values.videoRecorder.enabled }}
470470
{{- tpl (include "seleniumGrid.video.volumes" .) $ | nindent 6 }}
471471
{{- end }}
472472
{{- end -}}

0 commit comments

Comments
 (0)