Skip to content

Commit

Permalink
chart: Allow overwrite config videoRecorder in each node (#2445)
Browse files Browse the repository at this point in the history
Signed-off-by: Viet Nguyen Duc <nguyenducviet4496@gmail.com>
  • Loading branch information
VietND96 authored Oct 27, 2024
1 parent a5e252c commit 1fdc58b
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 30 deletions.
3 changes: 3 additions & 0 deletions charts/selenium-grid/CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes
| chromeNode.hpa.unsafeSsl | string | `"{{ template \"seleniumGrid.graphqlURL.unsafeSsl\" . }}"` | Skip check SSL when connecting to the Graphql endpoint |
| chromeNode.initContainers | list | `[]` | It is used to add initContainers in the same pod of the browser node. It should be set using the --set-json option |
| chromeNode.sidecars | list | `[]` | It is used to add sidecars proxy in the same pod of the browser node. It means it will add a new container to the deployment itself. It should be set using the --set-json option |
| chromeNode.videoRecorder | object | `{}` | Override specific video recording settings for chrome node |
| firefoxNode.enabled | bool | `true` | Enable firefox nodes |
| firefoxNode.deploymentEnabled | bool | `true` | NOTE: Only used when autoscaling.enabled is false Enable creation of Deployment true (default) - if you want long living pods false - for provisioning your own custom type such as Jobs |
| firefoxNode.updateStrategy | object | `{"type":"RollingUpdate"}` | Global update strategy will be overwritten by individual component |
Expand Down Expand Up @@ -446,6 +447,7 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes
| firefoxNode.hpa.unsafeSsl | string | `"{{ template \"seleniumGrid.graphqlURL.unsafeSsl\" . }}"` | Skip check SSL when connecting to the Graphql endpoint |
| firefoxNode.initContainers | list | `[]` | It is used to add initContainers in the same pod of the browser node. It should be set using the --set-json option |
| firefoxNode.sidecars | list | `[]` | It is used to add sidecars proxy in the same pod of the browser node. It means it will add a new container to the deployment itself. It should be set using the --set-json option |
| firefoxNode.videoRecorder | object | `{}` | Override specific video recording settings for firefox node |
| edgeNode.enabled | bool | `true` | Enable edge nodes |
| edgeNode.deploymentEnabled | bool | `true` | NOTE: Only used when autoscaling.enabled is false Enable creation of Deployment true (default) - if you want long living pods false - for provisioning your own custom type such as Jobs |
| edgeNode.updateStrategy | object | `{"type":"RollingUpdate"}` | Global update strategy will be overwritten by individual component |
Expand Down Expand Up @@ -496,6 +498,7 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes
| edgeNode.hpa.unsafeSsl | string | `"{{ template \"seleniumGrid.graphqlURL.unsafeSsl\" . }}"` | Skip check SSL when connecting to the Graphql endpoint |
| edgeNode.initContainers | list | `[]` | It is used to add initContainers in the same pod of the browser node. It should be set using the --set-json option |
| edgeNode.sidecars | list | `[]` | It is used to add sidecars proxy in the same pod of the browser node. It means it will add a new container to the deployment itself. It should be set using the --set-json option |
| edgeNode.videoRecorder | object | `{}` | Override specific video recording settings for edge node |
| videoRecorder.enabled | bool | `false` | Enable video recording in all browser nodes |
| videoRecorder.name | string | `"video"` | Container name is set to resource specs |
| videoRecorder.imageRegistry | string | `nil` | Registry to pull the image (this overwrites global.seleniumGrid.imageRegistry parameter) |
Expand Down
48 changes: 24 additions & 24 deletions charts/selenium-grid/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,8 @@ Common pod template
{{- define "seleniumGrid.podTemplate" -}}
{{- $nodeImageRegistry := default $.Values.global.seleniumGrid.imageRegistry .node.imageRegistry -}}
{{- $nodeImageTag := default $.Values.global.seleniumGrid.nodesImageTag .node.imageTag -}}
{{- $videoImageRegistry := default $.Values.global.seleniumGrid.imageRegistry $.Values.videoRecorder.imageRegistry -}}
{{- $videoImageTag := default $.Values.global.seleniumGrid.videoImageTag $.Values.videoRecorder.imageTag -}}
{{- $videoImageRegistry := default $.Values.global.seleniumGrid.imageRegistry .recorder.imageRegistry -}}
{{- $videoImageTag := default $.Values.global.seleniumGrid.videoImageTag .recorder.imageTag -}}
{{- $nodeMaxSessions := default $.Values.global.seleniumGrid.nodeMaxSessions .node.nodeMaxSessions | int64 -}}
template:
metadata:
Expand Down Expand Up @@ -315,11 +315,11 @@ template:
{{- with .node.resources }}
resources: {{- toYaml . | nindent 10 }}
{{- end }}
{{- if $.Values.videoRecorder.enabled }}
- name: "pre-puller-{{ $.Values.videoRecorder.name }}"
image: {{ printf "%s/%s:%s" $videoImageRegistry $.Values.videoRecorder.imageName $videoImageTag }}
{{- if .recorder.enabled }}
- name: "pre-puller-{{ .recorder.name }}"
image: {{ printf "%s/%s:%s" $videoImageRegistry .recorder.imageName $videoImageTag }}
command: ["bash", "-c", "'true'"]
{{- with $.Values.videoRecorder.resources }}
{{- with .recorder.resources }}
resources: {{- toYaml . | nindent 10 }}
{{- end }}
{{- end }}
Expand Down Expand Up @@ -478,10 +478,10 @@ template:
{{- if .node.sidecars }}
{{- toYaml .node.sidecars | nindent 6 }}
{{- end }}
{{- if $.Values.videoRecorder.enabled }}
- name: {{ $.Values.videoRecorder.name }}
image: {{ printf "%s/%s:%s" $videoImageRegistry $.Values.videoRecorder.imageName $videoImageTag }}
imagePullPolicy: {{ $.Values.videoRecorder.imagePullPolicy }}
{{- if .recorder.enabled }}
- name: {{ .recorder.name }}
image: {{ printf "%s/%s:%s" $videoImageRegistry .recorder.imageName $videoImageTag }}
imagePullPolicy: {{ .recorder.imagePullPolicy }}
env:
- name: SE_NODE_MAX_SESSIONS
value: {{ $nodeMaxSessions | quote }}
Expand All @@ -493,7 +493,7 @@ template:
valueFrom:
fieldRef:
fieldPath: status.podIP
{{- with $.Values.videoRecorder.extraEnvironmentVariables }}
{{- with .recorder.extraEnvironmentVariables }}
{{- tpl (toYaml .) $ | nindent 8 }}
{{- end }}
envFrom:
Expand All @@ -507,16 +507,16 @@ template:
name: {{ template "seleniumGrid.server.configmap.fullname" $ }}
- secretRef:
name: {{ template "seleniumGrid.basicAuth.secrets.fullname" $ }}
{{- if and $.Values.videoRecorder.uploader.enabled (empty $.Values.videoRecorder.uploader.name) }}
{{- if and .recorder.uploader.enabled (empty .recorder.uploader.name) }}
- secretRef:
name: {{ tpl (default (include "seleniumGrid.common.secrets.fullname" $) $.Values.uploaderConfigMap.secretVolumeMountName) $ }}
{{- end }}
{{- with $.Values.videoRecorder.extraEnvFrom }}
{{- with .recorder.extraEnvFrom }}
{{- tpl (toYaml .) $ | nindent 8 }}
{{- end }}
{{- if gt (len $.Values.videoRecorder.ports) 0 }}
{{- if gt (len .recorder.ports) 0 }}
ports:
{{- range $.Values.videoRecorder.ports }}
{{- range .recorder.ports }}
- containerPort: {{ . }}
protocol: TCP
{{- end }}
Expand All @@ -527,23 +527,23 @@ template:
mountPath: /dev/shm
{{- end }}
{{- tpl (include "seleniumGrid.video.volumeMounts" .) $ | nindent 8 }}
{{- with $.Values.videoRecorder.resources }}
{{- with .recorder.resources }}
resources: {{- toYaml . | nindent 10 }}
{{- end }}
{{- with $.Values.videoRecorder.securityContext }}
{{- with .recorder.securityContext }}
securityContext: {{- toYaml . | nindent 10 }}
{{- end }}
{{- with $.Values.videoRecorder.startupProbe }}
{{- with .recorder.startupProbe }}
startupProbe: {{- toYaml . | nindent 10 }}
{{- end }}
{{- with $.Values.videoRecorder.livenessProbe }}
{{- with .recorder.livenessProbe }}
livenessProbe: {{- toYaml . | nindent 10 }}
{{- end }}
{{- with $.Values.videoRecorder.lifecycle }}
{{- with .recorder.lifecycle }}
lifecycle: {{- toYaml . | nindent 10 }}
{{- end }}
{{- if and $.Values.videoRecorder.uploader.enabled (not (empty $.Values.videoRecorder.uploader.name)) }}
- name: {{ default "uploader" $.Values.videoRecorder.uploader.name }}
{{- if and .recorder.uploader.enabled (not (empty .recorder.uploader.name)) }}
- name: {{ default "uploader" .recorder.uploader.name }}
{{- $imageTag := .uploader.imageTag }}
{{- $imageRegistry := .uploader.imageRegistry }}
image: {{ printf "%s/%s:%s" $imageRegistry .uploader.imageName $imageTag }}
Expand All @@ -556,7 +556,7 @@ template:
{{- if .uploader.args }}
args: {{- tpl (toYaml .uploader.args) $ | nindent 8 }}
{{- else }}
args: ["-c", "{{ $.Values.recorderConfigMap.extraScriptsDirectory }}/{{ $.Values.videoRecorder.uploader.entryPointFileName }}"]
args: ["-c", "{{ $.Values.recorderConfigMap.extraScriptsDirectory }}/{{ .recorder.uploader.entryPointFileName }}"]
{{- end }}
{{- with .uploader.extraEnvironmentVariables }}
env: {{- tpl (toYaml .) $ | nindent 8 }}
Expand Down Expand Up @@ -632,7 +632,7 @@ template:
{{- if .node.extraVolumes }}
{{ tpl (toYaml .node.extraVolumes) $ | nindent 6 }}
{{- end }}
{{- if $.Values.videoRecorder.enabled }}
{{- if .recorder.enabled }}
{{- tpl (include "seleniumGrid.video.volumes" .) $ | nindent 6 }}
{{- end }}
{{- end -}}
Expand Down
3 changes: 2 additions & 1 deletion charts/selenium-grid/templates/chrome-node-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ spec:
{{- $podScope := deepCopy . -}}
{{- $_ := set $podScope "name" (include "seleniumGrid.chromeNode.fullname" .) -}}
{{- $_ = set $podScope "node" .Values.chromeNode -}}
{{- $_ = set $podScope "uploader" (get .Values.videoRecorder (.Values.videoRecorder.uploader.name | toString)) -}}
{{- $_ = set $podScope "recorder" (mergeOverwrite .Values.videoRecorder .Values.chromeNode.videoRecorder) -}}
{{- $_ = set $podScope "uploader" (get .Values.videoRecorder ($podScope.recorder.uploader.name | toString)) -}}
{{- include "seleniumGrid.podTemplate" $podScope | nindent 2 }}
{{- end }}
3 changes: 2 additions & 1 deletion charts/selenium-grid/templates/chrome-node-scaledjobs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ spec:
{{- $podScope := deepCopy . -}}
{{- $_ := set $podScope "name" (include "seleniumGrid.chromeNode.fullname" .) -}}
{{- $_ = set $podScope "node" .Values.chromeNode -}}
{{- $_ = set $podScope "uploader" (get .Values.videoRecorder (.Values.videoRecorder.uploader.name | toString)) -}}
{{- $_ = set $podScope "recorder" (mergeOverwrite .Values.videoRecorder .Values.chromeNode.videoRecorder) -}}
{{- $_ = set $podScope "uploader" (get .Values.videoRecorder ($podScope.recorder.uploader.name | toString)) -}}
{{- $_ = set $podScope "podTemplate" (include "seleniumGrid.podTemplate" $podScope | fromYaml) }}
{{- include "seleniumGrid.autoscalingTemplate" $podScope | nindent 2 }}
{{- end }}
3 changes: 2 additions & 1 deletion charts/selenium-grid/templates/edge-node-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ spec:
{{- $podScope := deepCopy . -}}
{{- $_ := set $podScope "name" (include "seleniumGrid.edgeNode.fullname" .) -}}
{{- $_ = set $podScope "node" .Values.edgeNode -}}
{{- $_ = set $podScope "uploader" (get .Values.videoRecorder (.Values.videoRecorder.uploader.name | toString)) -}}
{{- $_ = set $podScope "recorder" (mergeOverwrite .Values.videoRecorder .Values.edgeNode.videoRecorder) -}}
{{- $_ = set $podScope "uploader" (get .Values.videoRecorder ($podScope.recorder.uploader.name | toString)) -}}
{{- include "seleniumGrid.podTemplate" $podScope | nindent 2 }}
{{- end }}
3 changes: 2 additions & 1 deletion charts/selenium-grid/templates/edge-node-scaledjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ spec:
{{- $podScope := deepCopy . -}}
{{- $_ := set $podScope "name" (include "seleniumGrid.edgeNode.fullname" .) -}}
{{- $_ = set $podScope "node" .Values.edgeNode -}}
{{- $_ = set $podScope "uploader" (get .Values.videoRecorder (.Values.videoRecorder.uploader.name | toString)) -}}
{{- $_ = set $podScope "recorder" (mergeOverwrite .Values.videoRecorder .Values.edgeNode.videoRecorder) -}}
{{- $_ = set $podScope "uploader" (get .Values.videoRecorder ($podScope.recorder.uploader.name | toString)) -}}
{{- $_ = set $podScope "podTemplate" (include "seleniumGrid.podTemplate" $podScope | fromYaml) }}
{{- include "seleniumGrid.autoscalingTemplate" $podScope | nindent 2 }}
{{- end }}
3 changes: 2 additions & 1 deletion charts/selenium-grid/templates/firefox-node-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ spec:
{{- $podScope := deepCopy . -}}
{{- $_ := set $podScope "name" (include "seleniumGrid.firefoxNode.fullname" .) -}}
{{- $_ = set $podScope "node" .Values.firefoxNode -}}
{{- $_ = set $podScope "uploader" (get .Values.videoRecorder (.Values.videoRecorder.uploader.name | toString)) -}}
{{- $_ = set $podScope "recorder" (mergeOverwrite .Values.videoRecorder .Values.firefoxNode.videoRecorder) -}}
{{- $_ = set $podScope "uploader" (get .Values.videoRecorder ($podScope.recorder.uploader.name | toString)) -}}
{{- include "seleniumGrid.podTemplate" $podScope | nindent 2 }}
{{- end }}
3 changes: 2 additions & 1 deletion charts/selenium-grid/templates/firefox-node-scaledjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ spec:
{{- $podScope := deepCopy . -}}
{{- $_ := set $podScope "name" (include "seleniumGrid.firefoxNode.fullname" .) -}}
{{- $_ = set $podScope "node" .Values.firefoxNode -}}
{{- $_ = set $podScope "uploader" (get .Values.videoRecorder (.Values.videoRecorder.uploader.name | toString)) -}}
{{- $_ = set $podScope "recorder" (mergeOverwrite .Values.videoRecorder .Values.firefoxNode.videoRecorder) -}}
{{- $_ = set $podScope "uploader" (get .Values.videoRecorder ($podScope.recorder.uploader.name | toString)) -}}
{{- $_ = set $podScope "podTemplate" (include "seleniumGrid.podTemplate" $podScope | fromYaml) }}
{{- include "seleniumGrid.autoscalingTemplate" $podScope | nindent 2 }}
{{- end }}
7 changes: 7 additions & 0 deletions charts/selenium-grid/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1082,6 +1082,8 @@ chromeNode:
# It means it will add a new container to the deployment itself.
# It should be set using the --set-json option
sidecars: []
# -- Override specific video recording settings for chrome node
videoRecorder: {}

# Configuration for firefox nodes
firefoxNode:
Expand Down Expand Up @@ -1262,6 +1264,8 @@ firefoxNode:
# It means it will add a new container to the deployment itself.
# It should be set using the --set-json option
sidecars: []
# -- Override specific video recording settings for firefox node
videoRecorder: {}

# Configuration for edge nodes
edgeNode:
Expand Down Expand Up @@ -1442,7 +1446,10 @@ edgeNode:
# It means it will add a new container to the deployment itself.
# It should be set using the --set-json option
sidecars: []
# -- Override specific video recording settings for edge node
videoRecorder: {}

# Video recording configuration for all browser nodes. Can be overridden by each browser node
videoRecorder:
# -- Enable video recording in all browser nodes
enabled: false
Expand Down
3 changes: 3 additions & 0 deletions tests/charts/templates/render/dummy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ firefoxNode:
edgeNode:
annotations:
"restartOnUpdate": "true"
videoRecorder:
uploader:
enabled: false

videoRecorder:
enabled: true
Expand Down
3 changes: 3 additions & 0 deletions tests/charts/templates/render/dummy_solution.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ selenium-grid:

edgeNode:
affinity: *affinity
videoRecorder:
uploader:
enabled: false

videoRecorder:
enabled: true
Expand Down
4 changes: 4 additions & 0 deletions tests/charts/templates/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@ def test_upload_conf_mount_to_video_container(self):
video_container = container
if container['name'] == 's3':
uploader_container = container
# Test for case override upload config in Edge node
if doc['metadata']['name'] == '{0}selenium-edge-node'.format(RELEASE_NAME):
self.assertTrue(uploader_container is None, "Video uploader should be disabled in Edge node config")
continue
list_volume_mounts = None
if uploader_container is not None:
list_volume_mounts = uploader_container['volumeMounts']
Expand Down

0 comments on commit 1fdc58b

Please sign in to comment.