Skip to content

Commit

Permalink
K8s: Allow extra data set to EventBus and Node configmap (#2545)
Browse files Browse the repository at this point in the history
  • Loading branch information
VietND96 authored Dec 31, 2024
1 parent bd7876e commit 7d6ddb7
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 7 deletions.
2 changes: 2 additions & 0 deletions charts/selenium-grid/CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes
| ingress.paths | list | `[]` | List of paths for the ingress resource. This will override the default path |
| ingress.tls | list | `[]` | TLS backend configuration for ingress resource |
| busConfigMap.nameOverride | string | `nil` | Override the name of the bus configMap |
| busConfigMap.data | object | `{}` | Override or add extra data to the ConfigMap. The property that appears last within the ConfigMap overwrites any preceding values |
| busConfigMap.annotations | object | `{}` | Custom annotations for configmap |
| sessionMapConfigMap.nameOverride | string | `nil` | Override the name of the session map configMap |
| sessionMapConfigMap.annotations | object | `{}` | Custom annotations for configmap |
Expand All @@ -129,6 +130,7 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes
| routerConfigMap.scriptVolumeMountName | string | `nil` | Name of volume mount is used to mount scripts in the ConfigMap |
| routerConfigMap.annotations | object | `{}` | Custom annotations for configmap |
| nodeConfigMap.nameOverride | string | `nil` | Override the name of the node configMap |
| nodeConfigMap.data | object | `{}` | Override or add extra data to the ConfigMap. The property that appears last within the ConfigMap overwrites any preceding values |
| nodeConfigMap.defaultMode | int | `493` | Default mode for ConfigMap is mounted as file |
| nodeConfigMap.extraScriptsImportFrom | string | `"configs/node/**"` | Directory where the extra scripts are imported to ConfigMap by default (if given a relative path, it should be in chart's directory) |
| nodeConfigMap.extraScriptsDirectory | string | `"/opt/bin"` | Directory where the extra scripts are mounted to |
Expand Down
4 changes: 2 additions & 2 deletions charts/selenium-grid/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ Graphql Url for internal monitoring exporter
{{- end -}}

{{- define "seleniumGrid.url.host" -}}
{{- $host := printf "%s.%s" (include ($.Values.isolateComponents | ternary "seleniumGrid.router.fullname" "seleniumGrid.hub.fullname") $ ) (.Release.Namespace) -}}
{{- $host := printf "%s.%s.svc.cluster.local" (include ($.Values.isolateComponents | ternary "seleniumGrid.router.fullname" "seleniumGrid.hub.fullname") $ ) (.Release.Namespace) -}}
{{- if eq (include "seleniumGrid.ingress.enabled" $) "true" -}}
{{- if and (not .Values.ingress.hostname) .Values.global.K8S_PUBLIC_IP -}}
{{- $host = .Values.global.K8S_PUBLIC_IP -}}
Expand All @@ -721,7 +721,7 @@ Graphql Url for internal monitoring exporter
{{- end -}}

{{- define "seleniumGrid.server.url.host" -}}
{{- $host := printf "%s.%s" (include ($.Values.isolateComponents | ternary "seleniumGrid.router.fullname" "seleniumGrid.hub.fullname") $ ) (.Release.Namespace) -}}
{{- $host := printf "%s.%s.svc.cluster.local" (include ($.Values.isolateComponents | ternary "seleniumGrid.router.fullname" "seleniumGrid.hub.fullname") $ ) (.Release.Namespace) -}}
{{- $host }}
{{- end -}}

Expand Down
5 changes: 4 additions & 1 deletion charts/selenium-grid/templates/event-bus-configmap.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- $eventBusHost := printf "%s.%s" (ternary (include "seleniumGrid.eventBus.fullname" .) (include "seleniumGrid.hub.fullname" .) .Values.isolateComponents) (.Release.Namespace) -}}
{{- $eventBusHost := printf "%s.%s.svc.cluster.local" (ternary (include "seleniumGrid.eventBus.fullname" .) (include "seleniumGrid.hub.fullname" .) .Values.isolateComponents) (.Release.Namespace) -}}
{{- $eventBusPublishPort := ternary .Values.components.eventBus.publishPort .Values.hub.publishPort .Values.isolateComponents -}}
{{- $eventBusSubscribePort := ternary .Values.components.eventBus.subscribePort .Values.hub.subscribePort .Values.isolateComponents -}}
apiVersion: v1
Expand All @@ -18,3 +18,6 @@ data:
SE_EVENT_BUS_HOST: {{ $eventBusHost | quote }}
SE_EVENT_BUS_PUBLISH_PORT: {{ $eventBusPublishPort | quote }}
SE_EVENT_BUS_SUBSCRIBE_PORT: {{ $eventBusSubscribePort | quote }}
{{- with .Values.busConfigMap.data }}
{{- tpl (toYaml .) $ | nindent 2 }}
{{- end }}
12 changes: 9 additions & 3 deletions charts/selenium-grid/templates/node-configmap.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{{- $distributorHost := printf "%s.%s.svc.cluster.local" (include "seleniumGrid.distributor.fullname" .) (.Release.Namespace) -}}
{{- $routerHost := printf "%s.%s.svc.cluster.local" (include "seleniumGrid.router.fullname" .) (.Release.Namespace) -}}
{{- $hubHost := printf "%s.%s.svc.cluster.local" (include "seleniumGrid.hub.fullname" .) (.Release.Namespace) -}}
apiVersion: v1
kind: ConfigMap
metadata:
Expand All @@ -13,12 +16,12 @@ metadata:
{{- end }}
data:
{{- if .Values.isolateComponents }}
SE_DISTRIBUTOR_HOST: '{{ include "seleniumGrid.distributor.fullname" . }}.{{ .Release.Namespace }}'
SE_DISTRIBUTOR_HOST: {{ $distributorHost | quote }}
SE_DISTRIBUTOR_PORT: '{{ .Values.components.distributor.port }}'
SE_ROUTER_HOST: '{{ include "seleniumGrid.router.fullname" . }}.{{ .Release.Namespace }}'
SE_ROUTER_HOST: {{ $routerHost | quote }}
SE_ROUTER_PORT: '{{ .Values.components.router.port }}'
{{- else }}
SE_HUB_HOST: '{{ include "seleniumGrid.hub.fullname" . }}.{{ .Release.Namespace }}'
SE_HUB_HOST: {{ $hubHost | quote }}
SE_HUB_PORT: '{{ .Values.hub.port }}'
{{- end }}
NODE_CONFIG_DIRECTORY: '{{ $.Values.nodeConfigMap.extraScriptsDirectory }}'
Expand All @@ -38,6 +41,9 @@ data:
SE_BROWSER_LEFTOVERS_TEMPFILES_DAYS: '{{ . }}'
{{- end }}
{{- end }}
{{- with .Values.nodeConfigMap.data }}
{{- tpl (toYaml .) $ | nindent 2 }}
{{- end }}
{{- $fileProceeded := list -}}
{{- range $path, $_ := .Files.Glob $.Values.nodeConfigMap.extraScriptsImportFrom }}
{{- $fileName := base $path -}}
Expand Down
4 changes: 4 additions & 0 deletions charts/selenium-grid/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ ingress:
busConfigMap:
# -- Override the name of the bus configMap
nameOverride:
# -- Override or add extra data to the ConfigMap. The property that appears last within the ConfigMap overwrites any preceding values
data: {}
# -- Custom annotations for configmap
annotations: {}

Expand Down Expand Up @@ -282,6 +284,8 @@ routerConfigMap:
nodeConfigMap:
# -- Override the name of the node configMap
nameOverride:
# -- Override or add extra data to the ConfigMap. The property that appears last within the ConfigMap overwrites any preceding values
data: {}
# -- Default mode for ConfigMap is mounted as file
defaultMode: 0755
# -- Directory where the extra scripts are imported to ConfigMap by default (if given a relative path, it should be in chart's directory)
Expand Down
2 changes: 1 addition & 1 deletion tests/charts/templates/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def test_graphql_url_for_autoscaling_constructed_without_basic_auth_in_url(self)
logger.info(f"Assert graphql url is constructed without basic auth in url")
base64_url = doc['data']['SE_NODE_GRID_GRAPHQL_URL']
decoded_url = base64.b64decode(base64_url).decode('utf-8')
self.assertTrue(decoded_url == f'https://{RELEASE_NAME}selenium-router.default:4444/selenium/graphql', decoded_url)
self.assertTrue(decoded_url == f'https://{RELEASE_NAME}selenium-router.default.svc.cluster.local:4444/selenium/graphql', decoded_url)

def test_distributor_new_session_thread_pool_size(self):
resources_name = [f'{RELEASE_NAME}selenium-distributor']
Expand Down

0 comments on commit 7d6ddb7

Please sign in to comment.