Skip to content

Commit

Permalink
fix(chart): accessing .Values in templates (#2174)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
maxmanuylov authored Mar 26, 2024
1 parent db91598 commit 6f03eb1
Showing 1 changed file with 35 additions and 35 deletions.
70 changes: 35 additions & 35 deletions charts/selenium-grid/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -133,23 +133,23 @@ Common autoscaling spec template
{{- define "seleniumGrid.autoscalingTemplate" -}}
{{- $spec := toYaml (dict) -}}
{{/* Merge with precedence from right to left */}}
{{- with .Values.autoscaling.scaledOptions -}}
{{- with $.Values.autoscaling.scaledOptions -}}
{{- $spec = mergeOverwrite ($spec | fromYaml) . | toYaml -}}
{{- end -}}
{{- with .node.scaledOptions -}}
{{- $spec = mergeOverwrite ($spec | fromYaml) . | toYaml -}}
{{- end -}}
{{- if eq .Values.autoscaling.scalingType "deployment" -}}
{{- with .Values.autoscaling.scaledObjectOptions -}}
{{- if eq $.Values.autoscaling.scalingType "deployment" -}}
{{- with $.Values.autoscaling.scaledObjectOptions -}}
{{- $spec = mergeOverwrite ($spec | fromYaml) . | toYaml -}}
{{- end -}}
{{- with .node.scaledObjectOptions -}}
{{- $spec = mergeOverwrite ($spec | fromYaml) . | toYaml -}}
{{- end -}}
{{- $advanced := (dict "scaleTargetRef" (dict "name" .name) "advanced" (dict "horizontalPodAutoscalerConfig" (dict "name" .name) "restoreToOriginalReplicaCount" true)) -}}
{{- $spec = mergeOverwrite ($spec | fromYaml) $advanced | toYaml -}}
{{- else if eq .Values.autoscaling.scalingType "job" -}}
{{- with .Values.autoscaling.scaledJobOptions -}}
{{- else if eq $.Values.autoscaling.scalingType "job" -}}
{{- with $.Values.autoscaling.scaledJobOptions -}}
{{- $spec = mergeOverwrite ($spec | fromYaml) . | toYaml -}}
{{- end -}}
{{- with .node.scaledJobOptions -}}
Expand All @@ -160,7 +160,7 @@ Common autoscaling spec template
{{- if and $spec (ne $spec "{}") -}}
{{ tpl $spec $ }}
{{- end -}}
{{- if not .Values.autoscaling.scaledOptions.triggers }}
{{- if not $.Values.autoscaling.scaledOptions.triggers }}
triggers:
- type: selenium-grid
metadata:
Expand All @@ -184,7 +184,7 @@ template:
{{- with .node.labels }}
{{- toYaml . | nindent 6 }}
{{- end }}
{{- with .Values.customLabels }}
{{- with $.Values.customLabels }}
{{- toYaml . | nindent 6 }}
{{- end }}
annotations:
Expand All @@ -208,8 +208,8 @@ template:
{{- end }}
containers:
- name: {{ .name }}
{{- $imageTag := default .Values.global.seleniumGrid.nodesImageTag .node.imageTag }}
{{- $imageRegistry := default .Values.global.seleniumGrid.imageRegistry .node.imageRegistry }}
{{- $imageTag := default $.Values.global.seleniumGrid.nodesImageTag .node.imageTag }}
{{- $imageRegistry := default $.Values.global.seleniumGrid.imageRegistry .node.imageRegistry }}
image: {{ printf "%s/%s:%s" $imageRegistry .node.imageName $imageTag }}
imagePullPolicy: {{ .node.imagePullPolicy }}
env:
Expand Down Expand Up @@ -259,14 +259,14 @@ template:
volumeMounts:
- name: dshm
mountPath: /dev/shm
{{- range $fileName, $value := .Values.nodeConfigMap.extraScripts }}
{{- range $fileName, $value := $.Values.nodeConfigMap.extraScripts }}
- name: {{ tpl (default (include "seleniumGrid.node.configmap.fullname" $) $.Values.nodeConfigMap.scriptVolumeMountName) $ }}
mountPath: {{ $.Values.nodeConfigMap.extraScriptsDirectory }}/{{ $fileName }}
subPath: {{ $fileName }}
{{- end }}
{{- if .Values.tls.enabled }}
{{- if $.Values.tls.enabled }}
- name: {{ include "seleniumGrid.tls.fullname" $ | quote }}
mountPath: {{ .Values.serverConfigMap.certVolumeMountPath }}
mountPath: {{ $.Values.serverConfigMap.certVolumeMountPath }}
readOnly: true
{{- end }}
{{- if .node.extraVolumeMounts }}
Expand Down Expand Up @@ -336,20 +336,20 @@ template:
{{- if .node.sidecars }}
{{- toYaml .node.sidecars | nindent 6 }}
{{- end }}
{{- if .Values.videoRecorder.enabled }}
{{- if $.Values.videoRecorder.enabled }}
- name: video
{{- $imageTag := default .Values.global.seleniumGrid.videoImageTag .Values.videoRecorder.imageTag }}
{{- $imageRegistry := default .Values.global.seleniumGrid.imageRegistry .Values.videoRecorder.imageRegistry }}
image: {{ printf "%s/%s:%s" $imageRegistry .Values.videoRecorder.imageName $imageTag }}
imagePullPolicy: {{ .Values.videoRecorder.imagePullPolicy }}
{{- $imageTag := default $.Values.global.seleniumGrid.videoImageTag $.Values.videoRecorder.imageTag }}
{{- $imageRegistry := default $.Values.global.seleniumGrid.imageRegistry $.Values.videoRecorder.imageRegistry }}
image: {{ printf "%s/%s:%s" $imageRegistry $.Values.videoRecorder.imageName $imageTag }}
imagePullPolicy: {{ $.Values.videoRecorder.imagePullPolicy }}
env:
- name: SE_NODE_PORT
value: {{ .node.port | quote }}
- name: DISPLAY_CONTAINER_NAME
valueFrom:
fieldRef:
fieldPath: status.podIP
{{- with .Values.videoRecorder.extraEnvironmentVariables }}
{{- with $.Values.videoRecorder.extraEnvironmentVariables }}
{{- tpl (toYaml .) $ | nindent 8 }}
{{- end }}
envFrom:
Expand All @@ -361,16 +361,16 @@ template:
name: {{ template "seleniumGrid.recorder.configmap.fullname" $ }}
- configMapRef:
name: {{ template "seleniumGrid.server.configmap.fullname" $ }}
{{- if and .Values.videoRecorder.uploader.enabled (not .Values.videoRecorder.uploader.name) }}
{{- if and $.Values.videoRecorder.uploader.enabled (not $.Values.videoRecorder.uploader.name) }}
- secretRef:
name: {{ tpl (default (include "seleniumGrid.common.secrets.fullname" $) .Values.uploaderConfigMap.secretVolumeMountName) $ }}
name: {{ tpl (default (include "seleniumGrid.common.secrets.fullname" $) $.Values.uploaderConfigMap.secretVolumeMountName) $ }}
{{- end }}
{{- with .Values.videoRecorder.extraEnvFrom }}
{{- with $.Values.videoRecorder.extraEnvFrom }}
{{- tpl (toYaml .) $ | nindent 8 }}
{{- end }}
{{- if gt (len .Values.videoRecorder.ports) 0 }}
{{- if gt (len $.Values.videoRecorder.ports) 0 }}
ports:
{{- range .Values.videoRecorder.ports }}
{{- range $.Values.videoRecorder.ports }}
- containerPort: {{ . }}
protocol: TCP
{{- end }}
Expand All @@ -379,22 +379,22 @@ template:
- name: dshm
mountPath: /dev/shm
{{- tpl (include "seleniumGrid.video.volumeMounts" .) $ | nindent 8 }}
{{- with .Values.videoRecorder.resources }}
{{- with $.Values.videoRecorder.resources }}
resources: {{- toYaml . | nindent 10 }}
{{- end }}
{{- with .Values.videoRecorder.securityContext }}
{{- with $.Values.videoRecorder.securityContext }}
securityContext: {{- toYaml . | nindent 10 }}
{{- end }}
{{- with .Values.videoRecorder.startupProbe }}
{{- with $.Values.videoRecorder.startupProbe }}
startupProbe: {{- toYaml . | nindent 10 }}
{{- end }}
{{- with .Values.videoRecorder.livenessProbe }}
{{- with $.Values.videoRecorder.livenessProbe }}
livenessProbe: {{- toYaml . | nindent 10 }}
{{- end }}
{{- with .Values.videoRecorder.lifecycle }}
{{- with $.Values.videoRecorder.lifecycle }}
lifecycle: {{- toYaml . | nindent 10 }}
{{- end }}
{{- if and .Values.videoRecorder.uploader.enabled (not (empty .Values.videoRecorder.uploader.name)) }}
{{- if and $.Values.videoRecorder.uploader.enabled (not (empty $.Values.videoRecorder.uploader.name)) }}
- name: uploader
{{- $imageTag := .uploader.imageTag }}
{{- $imageRegistry := .uploader.imageRegistry }}
Expand All @@ -417,7 +417,7 @@ template:
- configMapRef:
name: {{ template "seleniumGrid.uploader.configmap.fullname" $ }}
- secretRef:
name: {{ tpl (default (include "seleniumGrid.common.secrets.fullname" $) .Values.uploaderConfigMap.secretVolumeMountName) $ }}
name: {{ tpl (default (include "seleniumGrid.common.secrets.fullname" $) $.Values.uploaderConfigMap.secretVolumeMountName) $ }}
{{- with .uploader.extraEnvFrom }}
{{- tpl (toYaml .) $ | nindent 10 }}
{{- end }}
Expand All @@ -431,9 +431,9 @@ template:
{{- end }}
{{- end }}
{{- end }}
{{- if or .Values.global.seleniumGrid.imagePullSecret .node.imagePullSecret }}
{{- if or $.Values.global.seleniumGrid.imagePullSecret .node.imagePullSecret }}
imagePullSecrets:
- name: {{ default .Values.global.seleniumGrid.imagePullSecret .node.imagePullSecret }}
- name: {{ default $.Values.global.seleniumGrid.imagePullSecret .node.imagePullSecret }}
{{- end }}
{{- with .node.nodeSelector }}
nodeSelector: {{- toYaml . | nindent 6 }}
Expand All @@ -453,20 +453,20 @@ template:
- name: {{ tpl (default (include "seleniumGrid.node.configmap.fullname" $) $.Values.nodeConfigMap.scriptVolumeMountName) $ }}
configMap:
name: {{ template "seleniumGrid.node.configmap.fullname" $ }}
defaultMode: {{ .Values.nodeConfigMap.defaultMode }}
defaultMode: {{ $.Values.nodeConfigMap.defaultMode }}
- name: dshm
emptyDir:
medium: Memory
sizeLimit: {{ default "1Gi" .node.dshmVolumeSizeLimit }}
{{- if .Values.tls.enabled }}
{{- if $.Values.tls.enabled }}
- name: {{ include "seleniumGrid.tls.fullname" $ | quote }}
secret:
secretName: {{ include "seleniumGrid.tls.fullname" $ | quote }}
{{- end }}
{{- if .node.extraVolumes }}
{{ tpl (toYaml .node.extraVolumes) $ | nindent 6 }}
{{- end }}
{{- if .Values.videoRecorder.enabled }}
{{- if $.Values.videoRecorder.enabled }}
{{- tpl (include "seleniumGrid.video.volumes" .) $ | nindent 6 }}
{{- end }}
{{- end -}}
Expand Down

0 comments on commit 6f03eb1

Please sign in to comment.