Skip to content

Commit 7d6ddb7

Browse files
authored
K8s: Allow extra data set to EventBus and Node configmap (#2545)
1 parent bd7876e commit 7d6ddb7

File tree

6 files changed

+22
-7
lines changed

6 files changed

+22
-7
lines changed

charts/selenium-grid/CONFIGURATION.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes
110110
| ingress.paths | list | `[]` | List of paths for the ingress resource. This will override the default path |
111111
| ingress.tls | list | `[]` | TLS backend configuration for ingress resource |
112112
| busConfigMap.nameOverride | string | `nil` | Override the name of the bus configMap |
113+
| busConfigMap.data | object | `{}` | Override or add extra data to the ConfigMap. The property that appears last within the ConfigMap overwrites any preceding values |
113114
| busConfigMap.annotations | object | `{}` | Custom annotations for configmap |
114115
| sessionMapConfigMap.nameOverride | string | `nil` | Override the name of the session map configMap |
115116
| sessionMapConfigMap.annotations | object | `{}` | Custom annotations for configmap |
@@ -129,6 +130,7 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes
129130
| routerConfigMap.scriptVolumeMountName | string | `nil` | Name of volume mount is used to mount scripts in the ConfigMap |
130131
| routerConfigMap.annotations | object | `{}` | Custom annotations for configmap |
131132
| nodeConfigMap.nameOverride | string | `nil` | Override the name of the node configMap |
133+
| nodeConfigMap.data | object | `{}` | Override or add extra data to the ConfigMap. The property that appears last within the ConfigMap overwrites any preceding values |
132134
| nodeConfigMap.defaultMode | int | `493` | Default mode for ConfigMap is mounted as file |
133135
| 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) |
134136
| nodeConfigMap.extraScriptsDirectory | string | `"/opt/bin"` | Directory where the extra scripts are mounted to |

charts/selenium-grid/templates/_helpers.tpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ Graphql Url for internal monitoring exporter
707707
{{- end -}}
708708

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

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

charts/selenium-grid/templates/event-bus-configmap.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- $eventBusHost := printf "%s.%s" (ternary (include "seleniumGrid.eventBus.fullname" .) (include "seleniumGrid.hub.fullname" .) .Values.isolateComponents) (.Release.Namespace) -}}
1+
{{- $eventBusHost := printf "%s.%s.svc.cluster.local" (ternary (include "seleniumGrid.eventBus.fullname" .) (include "seleniumGrid.hub.fullname" .) .Values.isolateComponents) (.Release.Namespace) -}}
22
{{- $eventBusPublishPort := ternary .Values.components.eventBus.publishPort .Values.hub.publishPort .Values.isolateComponents -}}
33
{{- $eventBusSubscribePort := ternary .Values.components.eventBus.subscribePort .Values.hub.subscribePort .Values.isolateComponents -}}
44
apiVersion: v1
@@ -18,3 +18,6 @@ data:
1818
SE_EVENT_BUS_HOST: {{ $eventBusHost | quote }}
1919
SE_EVENT_BUS_PUBLISH_PORT: {{ $eventBusPublishPort | quote }}
2020
SE_EVENT_BUS_SUBSCRIBE_PORT: {{ $eventBusSubscribePort | quote }}
21+
{{- with .Values.busConfigMap.data }}
22+
{{- tpl (toYaml .) $ | nindent 2 }}
23+
{{- end }}

charts/selenium-grid/templates/node-configmap.yaml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
{{- $distributorHost := printf "%s.%s.svc.cluster.local" (include "seleniumGrid.distributor.fullname" .) (.Release.Namespace) -}}
2+
{{- $routerHost := printf "%s.%s.svc.cluster.local" (include "seleniumGrid.router.fullname" .) (.Release.Namespace) -}}
3+
{{- $hubHost := printf "%s.%s.svc.cluster.local" (include "seleniumGrid.hub.fullname" .) (.Release.Namespace) -}}
14
apiVersion: v1
25
kind: ConfigMap
36
metadata:
@@ -13,12 +16,12 @@ metadata:
1316
{{- end }}
1417
data:
1518
{{- if .Values.isolateComponents }}
16-
SE_DISTRIBUTOR_HOST: '{{ include "seleniumGrid.distributor.fullname" . }}.{{ .Release.Namespace }}'
19+
SE_DISTRIBUTOR_HOST: {{ $distributorHost | quote }}
1720
SE_DISTRIBUTOR_PORT: '{{ .Values.components.distributor.port }}'
18-
SE_ROUTER_HOST: '{{ include "seleniumGrid.router.fullname" . }}.{{ .Release.Namespace }}'
21+
SE_ROUTER_HOST: {{ $routerHost | quote }}
1922
SE_ROUTER_PORT: '{{ .Values.components.router.port }}'
2023
{{- else }}
21-
SE_HUB_HOST: '{{ include "seleniumGrid.hub.fullname" . }}.{{ .Release.Namespace }}'
24+
SE_HUB_HOST: {{ $hubHost | quote }}
2225
SE_HUB_PORT: '{{ .Values.hub.port }}'
2326
{{- end }}
2427
NODE_CONFIG_DIRECTORY: '{{ $.Values.nodeConfigMap.extraScriptsDirectory }}'
@@ -38,6 +41,9 @@ data:
3841
SE_BROWSER_LEFTOVERS_TEMPFILES_DAYS: '{{ . }}'
3942
{{- end }}
4043
{{- end }}
44+
{{- with .Values.nodeConfigMap.data }}
45+
{{- tpl (toYaml .) $ | nindent 2 }}
46+
{{- end }}
4147
{{- $fileProceeded := list -}}
4248
{{- range $path, $_ := .Files.Glob $.Values.nodeConfigMap.extraScriptsImportFrom }}
4349
{{- $fileName := base $path -}}

charts/selenium-grid/values.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,8 @@ ingress:
232232
busConfigMap:
233233
# -- Override the name of the bus configMap
234234
nameOverride:
235+
# -- Override or add extra data to the ConfigMap. The property that appears last within the ConfigMap overwrites any preceding values
236+
data: {}
235237
# -- Custom annotations for configmap
236238
annotations: {}
237239

@@ -282,6 +284,8 @@ routerConfigMap:
282284
nodeConfigMap:
283285
# -- Override the name of the node configMap
284286
nameOverride:
287+
# -- Override or add extra data to the ConfigMap. The property that appears last within the ConfigMap overwrites any preceding values
288+
data: {}
285289
# -- Default mode for ConfigMap is mounted as file
286290
defaultMode: 0755
287291
# -- Directory where the extra scripts are imported to ConfigMap by default (if given a relative path, it should be in chart's directory)

tests/charts/templates/test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def test_graphql_url_for_autoscaling_constructed_without_basic_auth_in_url(self)
8080
logger.info(f"Assert graphql url is constructed without basic auth in url")
8181
base64_url = doc['data']['SE_NODE_GRID_GRAPHQL_URL']
8282
decoded_url = base64.b64decode(base64_url).decode('utf-8')
83-
self.assertTrue(decoded_url == f'https://{RELEASE_NAME}selenium-router.default:4444/selenium/graphql', decoded_url)
83+
self.assertTrue(decoded_url == f'https://{RELEASE_NAME}selenium-router.default.svc.cluster.local:4444/selenium/graphql', decoded_url)
8484

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

0 commit comments

Comments
 (0)