Skip to content

Commit 80856d3

Browse files
committed
feat(chart): option to disable release name prefix in object naming
Fix: #2147 When helm upgrade -i `selenium` [args] Signed-off-by: Viet Nguyen Duc <[email protected]>
1 parent b72e144 commit 80856d3

File tree

5 files changed

+51
-21
lines changed

5 files changed

+51
-21
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ chart_test_autoscaling_deployment:
457457
./tests/charts/make/chart_test.sh DeploymentAutoscaling
458458

459459
chart_test_autoscaling_job_https:
460-
SELENIUM_GRID_TEST_HEADLESS=true SELENIUM_GRID_PROTOCOL=https CHART_ENABLE_BASIC_AUTH=true SELENIUM_GRID_PORT=443 \
460+
SELENIUM_GRID_TEST_HEADLESS=true SELENIUM_GRID_PROTOCOL=https CHART_ENABLE_BASIC_AUTH=true RELEASE_NAME=selenium SELENIUM_GRID_PORT=443 \
461461
VERSION=$(TAG_VERSION) VIDEO_TAG=$(FFMPEG_TAG_VERSION)-$(BUILD_DATE) NAMESPACE=$(NAMESPACE) \
462462
./tests/charts/make/chart_test.sh JobAutoscaling
463463

@@ -467,7 +467,7 @@ chart_test_autoscaling_job_hostname:
467467
./tests/charts/make/chart_test.sh JobAutoscaling
468468

469469
chart_test_autoscaling_job:
470-
CHART_ENABLE_TRACING=true CHART_FULL_DISTRIBUTED_MODE=true CHART_ENABLE_INGRESS_HOSTNAME=true \
470+
CHART_ENABLE_TRACING=true CHART_FULL_DISTRIBUTED_MODE=true CHART_ENABLE_INGRESS_HOSTNAME=true RELEASE_NAME=selenium \
471471
VERSION=$(TAG_VERSION) VIDEO_TAG=$(FFMPEG_TAG_VERSION)-$(BUILD_DATE) NAMESPACE=$(NAMESPACE) \
472472
./tests/charts/make/chart_test.sh JobAutoscaling
473473

charts/selenium-grid/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ This chart enables the creation of a Selenium Grid Server in Kubernetes.
99
* [Introduction](#introduction)
1010
* [Installing the chart](#installing-the-chart)
1111
* [Installing the Nightly chart](#installing-the-nightly-chart)
12+
* [Chart Release Name convention](#chart-release-name-convention)
1213
* [Enable Selenium Grid Autoscaling](#enable-selenium-grid-autoscaling)
1314
* [Settings common for both `job` and `deployment` scalingType](#settings-common-for-both-job-and-deployment-scalingtype)
1415
* [Settings when scalingType with `deployment`](#settings-when-scalingtype-with-deployment-)
@@ -88,6 +89,20 @@ helm search repo docker-selenium --devel
8889
helm install selenium-grid docker-selenium/selenium-grid --version 1.0.0-nightly
8990
```
9091

92+
### Chart Release Name convention
93+
94+
By default, all objects created by the chart will be prefixed with the release name. This is to avoid conflicts with other installations of the chart in the same namespace.
95+
96+
- If you want to disable this behavior, you can deploy the chart with the release name is `selenium`.
97+
- You can override the component name via `.nameOverride` in a respective component. For example
98+
99+
```yaml
100+
hub:
101+
nameOverride: my-hub-name
102+
chromeNode:
103+
nameOverride: my-chrome-name
104+
```
105+
91106
## Enable Selenium Grid Autoscaling
92107
93108
Selenium Grid has the ability to autoscaling browser nodes up/down based on the pending requests in the

charts/selenium-grid/templates/_nameHelpers.tpl

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,28 @@ app.kubernetes.io/component: {{ printf "selenium-grid-%s" .Chart.AppVersion }}
3939
helm.sh/chart: {{ include "seleniumGrid.chart" . }}
4040
{{- end -}}
4141

42+
{{- define "seleniumGrid.component.name" -}}
43+
{{- $component := index . 0 }}
44+
{{- $root := index . 1 }}
45+
{{- if eq $root.Release.Name "selenium" }}
46+
{{- $component | trunc 63 | trimSuffix "-" -}}
47+
{{- else -}}
48+
{{- printf "%s-%s" $root.Release.Name $component | trunc 63 | trimSuffix "-" -}}
49+
{{- end -}}
50+
{{- end -}}
51+
4252
{{/*
4353
Selenium Hub fullname
4454
*/}}
4555
{{- define "seleniumGrid.hub.fullname" -}}
46-
{{- tpl (default (printf "%s-selenium-hub" .Release.Name) .Values.hub.nameOverride) $ | trunc 63 | trimSuffix "-" -}}
56+
{{- tpl (default (include "seleniumGrid.component.name" (list "selenium-hub" $)) .Values.hub.nameOverride) $ | trunc 63 | trimSuffix "-" -}}
4757
{{- end -}}
4858

4959
{{/*
5060
Event bus fullname
5161
*/}}
5262
{{- define "seleniumGrid.eventBus.fullname" -}}
53-
{{- tpl (default (printf "%s-selenium-event-bus" .Release.Name) .Values.components.eventBus.nameOverride) $ | trunc 63 | trimSuffix "-" -}}
63+
{{- tpl (default (include "seleniumGrid.component.name" (list "selenium-event-bus" $)) .Values.components.eventBus.nameOverride) $ | trunc 63 | trimSuffix "-" | trimPrefix "selenium-" -}}
5464
{{- end -}}
5565

5666
{{/*
@@ -64,110 +74,110 @@ Event bus ConfigMap fullname
6474
Router fullname
6575
*/}}
6676
{{- define "seleniumGrid.router.fullname" -}}
67-
{{- tpl (default (printf "%s-selenium-router" .Release.Name) .Values.components.router.nameOverride) $ | trunc 63 | trimSuffix "-" -}}
77+
{{- tpl (default (include "seleniumGrid.component.name" (list "selenium-router" $)) .Values.components.router.nameOverride) $ | trunc 63 | trimSuffix "-" -}}
6878
{{- end -}}
6979

7080
{{/*
7181
Distributor fullname
7282
*/}}
7383
{{- define "seleniumGrid.distributor.fullname" -}}
74-
{{- tpl (default (printf "%s-selenium-distributor" .Release.Name) .Values.components.distributor.nameOverride) $ | trunc 63 | trimSuffix "-" -}}
84+
{{- tpl (default (include "seleniumGrid.component.name" (list "selenium-distributor" $)) .Values.components.distributor.nameOverride) $ | trunc 63 | trimSuffix "-" -}}
7585
{{- end -}}
7686

7787
{{/*
7888
SessionMap fullname
7989
*/}}
8090
{{- define "seleniumGrid.sessionMap.fullname" -}}
81-
{{- tpl (default (printf "%s-selenium-session-map" .Release.Name) .Values.components.sessionMap.nameOverride) $ | trunc 63 | trimSuffix "-" -}}
91+
{{- tpl (default (include "seleniumGrid.component.name" (list "selenium-session-map" $)) .Values.components.sessionMap.nameOverride) $ | trunc 63 | trimSuffix "-" -}}
8292
{{- end -}}
8393

8494
{{/*
8595
SessionQueue fullname
8696
*/}}
8797
{{- define "seleniumGrid.sessionQueue.fullname" -}}
88-
{{- tpl (default (printf "%s-selenium-session-queue" .Release.Name) .Values.components.sessionQueue.nameOverride) $ | trunc 63 | trimSuffix "-" -}}
98+
{{- tpl (default (include "seleniumGrid.component.name" (list "selenium-session-queue" $)) .Values.components.sessionQueue.nameOverride) $ | trunc 63 | trimSuffix "-" -}}
8999
{{- end -}}
90100

91101
{{/*
92102
Chrome node fullname
93103
*/}}
94104
{{- define "seleniumGrid.chromeNode.fullname" -}}
95-
{{- tpl (default (printf "%s-selenium-chrome-node" .Release.Name) .Values.chromeNode.nameOverride) $ | trunc 63 | trimSuffix "-" -}}
105+
{{- tpl (default (include "seleniumGrid.component.name" (list "selenium-chrome-node" $)) .Values.chromeNode.nameOverride) $ | trunc 63 | trimSuffix "-" -}}
96106
{{- end -}}
97107

98108
{{/*
99109
Firefox node fullname
100110
*/}}
101111
{{- define "seleniumGrid.firefoxNode.fullname" -}}
102-
{{- tpl (default (printf "%s-selenium-firefox-node" .Release.Name) .Values.firefoxNode.nameOverride) $ | trunc 63 | trimSuffix "-" -}}
112+
{{- tpl (default (include "seleniumGrid.component.name" (list "selenium-firefox-node" $)) .Values.firefoxNode.nameOverride) $ | trunc 63 | trimSuffix "-" -}}
103113
{{- end -}}
104114

105115
{{/*
106116
Edge node fullname
107117
*/}}
108118
{{- define "seleniumGrid.edgeNode.fullname" -}}
109-
{{- tpl (default (printf "%s-selenium-edge-node" .Release.Name) .Values.edgeNode.nameOverride) $ | trunc 63 | trimSuffix "-" -}}
119+
{{- tpl (default (include "seleniumGrid.component.name" (list "selenium-edge-node" $)) .Values.edgeNode.nameOverride) $ | trunc 63 | trimSuffix "-" -}}
110120
{{- end -}}
111121

112122
{{/*
113123
Ingress fullname
114124
*/}}
115125
{{- define "seleniumGrid.ingress.fullname" -}}
116-
{{- tpl (default (printf "%s-selenium-ingress" .Release.Name) .Values.ingress.nameOverride) $ | trunc 63 | trimSuffix "-" -}}
126+
{{- tpl (default (include "seleniumGrid.component.name" (list "selenium-ingress" $)) .Values.ingress.nameOverride) $ | trunc 63 | trimSuffix "-" -}}
117127
{{- end -}}
118128

119129
{{/*
120130
Common secrets cross components
121131
*/}}
122132
{{- define "seleniumGrid.common.secrets.fullname" -}}
123-
{{- tpl (default (printf "%s-selenium-secrets" .Release.Name) .Values.secrets.nameOverride) $ | trunc 63 | trimSuffix "-" -}}
133+
{{- tpl (default (include "seleniumGrid.component.name" (list "selenium-secrets" $)) .Values.secrets.nameOverride) $ | trunc 63 | trimSuffix "-" -}}
124134
{{- end -}}
125135

126136
{{/*
127137
Secret TLS fullname
128138
*/}}
129139
{{- define "seleniumGrid.tls.fullname" -}}
130-
{{- tpl (default (printf "%s-selenium-tls-secret" .Release.Name) .Values.tls.nameOverride) $ | trunc 63 | trimSuffix "-" -}}
140+
{{- tpl (default (include "seleniumGrid.component.name" (list "selenium-tls-secret" $)) .Values.tls.nameOverride) $ | trunc 63 | trimSuffix "-" -}}
131141
{{- end -}}
132142

133143
{{/*
134144
Service Account fullname
135145
*/}}
136146
{{- define "seleniumGrid.serviceAccount.fullname" -}}
137-
{{- tpl (default (printf "%s-selenium-serviceaccount" .Release.Name) .Values.serviceAccount.nameOverride) $ | trunc 63 | trimSuffix "-" -}}
147+
{{- tpl (default (include "seleniumGrid.component.name" (list "selenium-serviceaccount" $)) .Values.serviceAccount.nameOverride) $ | trunc 63 | trimSuffix "-" -}}
138148
{{- end -}}
139149

140150
{{/*
141151
Recorder ConfigMap fullname
142152
*/}}
143153
{{- define "seleniumGrid.recorder.configmap.fullname" -}}
144-
{{- tpl (default (printf "%s-selenium-recorder-config" .Release.Name) .Values.recorderConfigMap.nameOverride) $ | trunc 63 | trimSuffix "-" -}}
154+
{{- tpl (default (include "seleniumGrid.component.name" (list "selenium-recorder-config" $)) .Values.recorderConfigMap.nameOverride) $ | trunc 63 | trimSuffix "-" -}}
145155
{{- end -}}
146156

147157
{{/*
148158
Uploader ConfigMap fullname
149159
*/}}
150160
{{- define "seleniumGrid.uploader.configmap.fullname" -}}
151-
{{- tpl (default (printf "%s-selenium-uploader-config" .Release.Name) .Values.uploaderConfigMap.nameOverride) $ | trunc 63 | trimSuffix "-" -}}
161+
{{- tpl (default (include "seleniumGrid.component.name" (list "selenium-uploader-config" $)) .Values.uploaderConfigMap.nameOverride) $ | trunc 63 | trimSuffix "-" -}}
152162
{{- end -}}
153163

154164
{{/*
155165
Logging ConfigMap fullname
156166
*/}}
157167
{{- define "seleniumGrid.logging.configmap.fullname" -}}
158-
{{- tpl (default (printf "%s-selenium-logging-config" .Release.Name) .Values.loggingConfigMap.nameOverride) $ | trunc 63 | trimSuffix "-" -}}
168+
{{- tpl (default (include "seleniumGrid.component.name" (list "selenium-logging-config" $)) .Values.loggingConfigMap.nameOverride) $ | trunc 63 | trimSuffix "-" -}}
159169
{{- end -}}
160170

161171
{{/*
162172
Node ConfigMap fullname
163173
*/}}
164174
{{- define "seleniumGrid.node.configmap.fullname" -}}
165-
{{- tpl (default (printf "%s-selenium-node-config" .Release.Name) .Values.nodeConfigMap.nameOverride) $ | trunc 63 | trimSuffix "-" -}}
175+
{{- tpl (default (include "seleniumGrid.component.name" (list "selenium-node-config" $)) .Values.nodeConfigMap.nameOverride) $ | trunc 63 | trimSuffix "-" -}}
166176
{{- end -}}
167177

168178
{{/*
169179
Server ConfigMap fullname
170180
*/}}
171181
{{- define "seleniumGrid.server.configmap.fullname" -}}
172-
{{- tpl (default (printf "%s-selenium-server-config" .Release.Name) .Values.serverConfigMap.nameOverride) $ | trunc 63 | trimSuffix "-" -}}
182+
{{- tpl (default (include "seleniumGrid.component.name" (list "selenium-server-config" $)) .Values.serverConfigMap.nameOverride) $ | trunc 63 | trimSuffix "-" -}}
173183
{{- end -}}

tests/charts/ci/base-recorder-values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ videoRecorder:
3737
ingress-nginx:
3838
controller:
3939
extraArgs:
40-
default-ssl-certificate: '$(POD_NAMESPACE)/${RELEASE_NAME}-selenium-tls-secret'
40+
default-ssl-certificate: '$(POD_NAMESPACE)/${SELENIUM_TLS_SECRET_NAME}'

tests/charts/make/chart_test.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ else
6565
export UPLOAD_ENABLED=false
6666
fi
6767
export RELEASE_NAME=${RELEASE_NAME}
68+
if [ "${RELEASE_NAME}" = "selenium" ]; then
69+
export SELENIUM_TLS_SECRET_NAME="selenium-tls-secret"
70+
else
71+
export SELENIUM_TLS_SECRET_NAME="${RELEASE_NAME}-selenium-tls-secret"
72+
fi
6873
RECORDER_VALUES_FILE=${TEST_VALUES_PATH}/base-recorder-values.yaml
6974
envsubst < ${RECORDER_VALUES_FILE} > ./tests/tests/base-recorder-values.yaml
7075
RECORDER_VALUES_FILE=./tests/tests/base-recorder-values.yaml

0 commit comments

Comments
 (0)