From 1fdc58bf072b7a276d8f33639a681f1d1c7cd3bc Mon Sep 17 00:00:00 2001 From: Viet Nguyen Duc Date: Sun, 27 Oct 2024 13:23:48 +0000 Subject: [PATCH] chart: Allow overwrite config videoRecorder in each node (#2445) Signed-off-by: Viet Nguyen Duc --- charts/selenium-grid/CONFIGURATION.md | 3 ++ charts/selenium-grid/templates/_helpers.tpl | 48 +++++++++---------- .../templates/chrome-node-deployment.yaml | 3 +- .../templates/chrome-node-scaledjobs.yaml | 3 +- .../templates/edge-node-deployment.yaml | 3 +- .../templates/edge-node-scaledjob.yaml | 3 +- .../templates/firefox-node-deployment.yaml | 3 +- .../templates/firefox-node-scaledjob.yaml | 3 +- charts/selenium-grid/values.yaml | 7 +++ tests/charts/templates/render/dummy.yaml | 3 ++ .../templates/render/dummy_solution.yaml | 3 ++ tests/charts/templates/test.py | 4 ++ 12 files changed, 56 insertions(+), 30 deletions(-) diff --git a/charts/selenium-grid/CONFIGURATION.md b/charts/selenium-grid/CONFIGURATION.md index e9f699450..4f0a7097c 100644 --- a/charts/selenium-grid/CONFIGURATION.md +++ b/charts/selenium-grid/CONFIGURATION.md @@ -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 | @@ -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 | @@ -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) | diff --git a/charts/selenium-grid/templates/_helpers.tpl b/charts/selenium-grid/templates/_helpers.tpl index 74acebcb1..3873c5c2b 100644 --- a/charts/selenium-grid/templates/_helpers.tpl +++ b/charts/selenium-grid/templates/_helpers.tpl @@ -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: @@ -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 }} @@ -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 }} @@ -493,7 +493,7 @@ template: valueFrom: fieldRef: fieldPath: status.podIP - {{- with $.Values.videoRecorder.extraEnvironmentVariables }} + {{- with .recorder.extraEnvironmentVariables }} {{- tpl (toYaml .) $ | nindent 8 }} {{- end }} envFrom: @@ -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 }} @@ -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 }} @@ -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 }} @@ -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 -}} diff --git a/charts/selenium-grid/templates/chrome-node-deployment.yaml b/charts/selenium-grid/templates/chrome-node-deployment.yaml index d289c66ef..930239934 100644 --- a/charts/selenium-grid/templates/chrome-node-deployment.yaml +++ b/charts/selenium-grid/templates/chrome-node-deployment.yaml @@ -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 }} diff --git a/charts/selenium-grid/templates/chrome-node-scaledjobs.yaml b/charts/selenium-grid/templates/chrome-node-scaledjobs.yaml index c858908ce..d49e39d0a 100644 --- a/charts/selenium-grid/templates/chrome-node-scaledjobs.yaml +++ b/charts/selenium-grid/templates/chrome-node-scaledjobs.yaml @@ -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 }} diff --git a/charts/selenium-grid/templates/edge-node-deployment.yaml b/charts/selenium-grid/templates/edge-node-deployment.yaml index a82248253..ac3ff3cb3 100644 --- a/charts/selenium-grid/templates/edge-node-deployment.yaml +++ b/charts/selenium-grid/templates/edge-node-deployment.yaml @@ -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 }} diff --git a/charts/selenium-grid/templates/edge-node-scaledjob.yaml b/charts/selenium-grid/templates/edge-node-scaledjob.yaml index e9cce337a..49875b055 100644 --- a/charts/selenium-grid/templates/edge-node-scaledjob.yaml +++ b/charts/selenium-grid/templates/edge-node-scaledjob.yaml @@ -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 }} diff --git a/charts/selenium-grid/templates/firefox-node-deployment.yaml b/charts/selenium-grid/templates/firefox-node-deployment.yaml index 29e01ffad..67c0d171b 100644 --- a/charts/selenium-grid/templates/firefox-node-deployment.yaml +++ b/charts/selenium-grid/templates/firefox-node-deployment.yaml @@ -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 }} diff --git a/charts/selenium-grid/templates/firefox-node-scaledjob.yaml b/charts/selenium-grid/templates/firefox-node-scaledjob.yaml index d65bf0b69..b72b0d89a 100644 --- a/charts/selenium-grid/templates/firefox-node-scaledjob.yaml +++ b/charts/selenium-grid/templates/firefox-node-scaledjob.yaml @@ -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 }} diff --git a/charts/selenium-grid/values.yaml b/charts/selenium-grid/values.yaml index 4f96949b5..de916f199 100644 --- a/charts/selenium-grid/values.yaml +++ b/charts/selenium-grid/values.yaml @@ -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: @@ -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: @@ -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 diff --git a/tests/charts/templates/render/dummy.yaml b/tests/charts/templates/render/dummy.yaml index bda017b5c..671c4c63b 100644 --- a/tests/charts/templates/render/dummy.yaml +++ b/tests/charts/templates/render/dummy.yaml @@ -131,6 +131,9 @@ firefoxNode: edgeNode: annotations: "restartOnUpdate": "true" + videoRecorder: + uploader: + enabled: false videoRecorder: enabled: true diff --git a/tests/charts/templates/render/dummy_solution.yaml b/tests/charts/templates/render/dummy_solution.yaml index d2fa0bb8b..45611b6d1 100644 --- a/tests/charts/templates/render/dummy_solution.yaml +++ b/tests/charts/templates/render/dummy_solution.yaml @@ -119,6 +119,9 @@ selenium-grid: edgeNode: affinity: *affinity + videoRecorder: + uploader: + enabled: false videoRecorder: enabled: true diff --git a/tests/charts/templates/test.py b/tests/charts/templates/test.py index 03e41fa3c..e291cabbd 100644 --- a/tests/charts/templates/test.py +++ b/tests/charts/templates/test.py @@ -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']