Skip to content

Commit fe28e0c

Browse files
ilpianistapedromctechdiemol
authored
Selenium Grid Helm Chart (#1508)
* First version of Helm chart for Selenium Grid server * Changelog added Signed-off-by: Pedro Miranda <[email protected]> * Version 0.2.0 implemented (See changelog) Signed-off-by: Pedro Miranda <[email protected]> * Disable components isolation by default Signed-off-by: Pedro Miranda <[email protected]> * Update image tag to 4.0.0-rc-1-prerelease-20210804 * Add support for tolerations * Add support for nodeSelector * Drop Opera from the chart * Fix empty value for tolerations * Add Edge nodes * Allow to add extra labels to hub, chrome, firefox and edge nodes * Update to 4.0.0-rc-1-prerelease-20210823 * Update to 4.0.0-rc-1-20210902 * Update to 4.0.0-rc-2-20210930 * Update to 4.0.0-rc-3-20211010 * Update to 4.0.0-20211013 * Update to 4.0.0-20211025 * Update to 4.1.0-20211123 * Update to 4.1.2-20220131 * Update to 4.1.2-20220208 * Fix queue component name (backport of 9353a18) * Update to 4.1.2-20220217 * Update chart/selenium-grid/README.md Co-authored-by: Diego Molina <[email protected]> Co-authored-by: Pedro Miranda <[email protected]> Co-authored-by: Diego Molina <[email protected]>
1 parent 6550263 commit fe28e0c

26 files changed

+1562
-0
lines changed

chart/selenium-grid/.helmignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/

chart/selenium-grid/CHANGELOG.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Change Log
2+
3+
All notable changes to this helm chart will be documented in this file.
4+
5+
## :heavy_check_mark: 0.3.0
6+
7+
### Added
8+
- Support for Edge nodes.
9+
- Support for `nodeSelector`.
10+
- Support for `tolerations`.
11+
- Allow to add additional labels to the hub, edge, firefox and chrome nodes.
12+
- Fix queue component name (#1290)
13+
14+
### Changed
15+
- Update image tag to 4.1.2-20220217
16+
17+
### Removed
18+
- Opera nodes
19+
20+
## :heavy_check_mark: 0.2.0
21+
22+
### Added
23+
- `CHANGELOG.md`
24+
25+
### Changed
26+
- Added `global` block to be able to specify component's image tag globally.
27+
- DSHM's volume size customizable.
28+
- Service type and service annotations are now customizable.
29+
30+
### Fixed
31+
- Services won't be created if nodes are disabled.
32+
33+
## :heavy_check_mark: 0.1.0
34+
35+
### Added
36+
- Selenium grid components separated.
37+
- Selenium Hub server.
38+
- Chrome, Opera and Firefox nodes.

chart/selenium-grid/Chart.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
apiVersion: v2
2+
name: selenium-grid
3+
description: A Helm chart for creating a Selenium grid server in Kubernetes
4+
type: application
5+
version: 0.3.0
6+
appVersion: 4.1.2-20220217

chart/selenium-grid/README.md

Lines changed: 183 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Selenium Grid Server deployed succesfully.
2+
3+
1. Get the URL FOR WebDriver tests by running these commands:
4+
5+
{{- $appName := ternary "selenium-router" "selenium-hub" .Values.isolateComponents }}
6+
{{- $serviceType := ternary .Values.components.router.serviceType .Values.hub.serviceType .Values.isolateComponents }}
7+
{{- $port := ternary .Values.components.router.port .Values.hub.port .Values.isolateComponents }}
8+
{{- $localUrl := ternary "http://localhost:PORT" "http://localhost:PORT/wd/hub" .Values.isolateComponents }}
9+
{{- if contains "NodePort" $serviceType }}
10+
export NODE_PORT=$(kubectl get -n {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" svc {{ include "seleniumGrid.router.fullname" . }})
11+
export NODE_IP=$(kubectl get nodes -n {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
12+
echo http://$NODE_IP:$NODE_PORT
13+
{{- else if contains "LoadBalancer" $serviceType }}
14+
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
15+
You can watch the status of by running 'kubectl get -n {{ .Release.Namespace }} svc -w {{ include "seleniumGrid.router.fullname" . }}'
16+
export SERVICE_IP=$(kubectl get svc -n {{ .Release.Namespace }} {{ include "seleniumGrid.router.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
17+
echo http://$SERVICE_IP:{{ $port }}
18+
{{- else if contains "ClusterIP" $serviceType }}
19+
export POD_NAME=$(kubectl get pods -n {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ $appName }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
20+
echo "Point your WebDriver tests to {{ $localUrl | replace "PORT" (toString $port) }}"
21+
kubectl -n {{ .Release.Namespace }} port-forward $POD_NAME {{ $port }}:{{ $port }}
22+
{{- end }}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
{{/*
2+
Common labels
3+
*/}}
4+
{{- define "seleniumGrid.commonLabels" -}}
5+
app.kubernetes.io/managed-by: {{ .Release.Service | lower }}
6+
app.kubernetes.io/instance: {{ .Release.Name }}
7+
app.kubernetes.io/version: {{ .Chart.AppVersion }}
8+
app.kubernetes.io/component: {{ printf "selenium-grid-%s" .Chart.AppVersion }}
9+
helm.sh/chart: {{ printf "%s-%s" .Chart.Name (.Chart.Version | replace "+" "_") }}
10+
{{- end -}}
11+
12+
{{/*
13+
Selenium Hub fullname
14+
*/}}
15+
{{- define "seleniumGrid.hub.fullname" -}}
16+
{{- default "selenium-hub" .Values.hub.nameOverride | trunc 63 | trimSuffix "-" -}}
17+
{{- end -}}
18+
19+
{{/*
20+
Event bus fullname
21+
*/}}
22+
{{- define "seleniumGrid.eventBus.fullname" -}}
23+
{{- default "selenium-event-bus" .Values.components.eventBus.nameOverride | trunc 63 | trimSuffix "-" -}}
24+
{{- end -}}
25+
26+
{{/*
27+
Router fullname
28+
*/}}
29+
{{- define "seleniumGrid.router.fullname" -}}
30+
{{- default "selenium-router" .Values.components.router.nameOverride | trunc 63 | trimSuffix "-" -}}
31+
{{- end -}}
32+
33+
{{/*
34+
Distributor fullname
35+
*/}}
36+
{{- define "seleniumGrid.distributor.fullname" -}}
37+
{{- default "selenium-distributor" .Values.components.distributor.nameOverride | trunc 63 | trimSuffix "-" -}}
38+
{{- end -}}
39+
40+
{{/*
41+
SessionMap fullname
42+
*/}}
43+
{{- define "seleniumGrid.sessionMap.fullname" -}}
44+
{{- default "selenium-session-map" .Values.components.sessionMap.nameOverride | trunc 63 | trimSuffix "-" -}}
45+
{{- end -}}
46+
47+
{{/*
48+
SessionQueue fullname
49+
*/}}
50+
{{- define "seleniumGrid.sessionQueue.fullname" -}}
51+
{{- default "selenium-session-queue" .Values.components.sessionQueue.nameOverride | trunc 63 | trimSuffix "-" -}}
52+
{{- end -}}
53+
54+
{{/*
55+
Chrome node fullname
56+
*/}}
57+
{{- define "seleniumGrid.chromeNode.fullname" -}}
58+
{{- default "selenium-chrome-node" .Values.chromeNode.nameOverride | trunc 63 | trimSuffix "-" -}}
59+
{{- end -}}
60+
61+
{{/*
62+
Firefox node fullname
63+
*/}}
64+
{{- define "seleniumGrid.firefoxNode.fullname" -}}
65+
{{- default "selenium-firefox-node" .Values.firefoxNode.nameOverride | trunc 63 | trimSuffix "-" -}}
66+
{{- end -}}
67+
68+
{{/*
69+
Edge node fullname
70+
*/}}
71+
{{- define "seleniumGrid.edgeNode.fullname" -}}
72+
{{- default "selenium-edge-node" .Values.edgeNode.nameOverride | trunc 63 | trimSuffix "-" -}}
73+
{{- end -}}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
{{- if .Values.chromeNode.enabled }}
2+
apiVersion: apps/v1
3+
kind: Deployment
4+
metadata:
5+
name: {{ template "seleniumGrid.chromeNode.fullname" . }}
6+
namespace: {{ .Release.Namespace }}
7+
labels: &chrome_node_labels
8+
app: selenium-chrome-node
9+
app.kubernetes.io/name: selenium-chrome-node
10+
{{- include "seleniumGrid.commonLabels" . | nindent 4 }}
11+
{{- with .Values.chromeNode.labels }}
12+
{{- toYaml . | nindent 4 }}
13+
{{- end }}
14+
{{- with .Values.customLabels }}
15+
{{- toYaml . | nindent 4 }}
16+
{{- end }}
17+
spec:
18+
replicas: {{ .Values.chromeNode.replicas }}
19+
selector:
20+
matchLabels:
21+
app: selenium-chrome-node
22+
template:
23+
metadata:
24+
labels: *chrome_node_labels
25+
annotations:
26+
checksum/event-bus-configmap: {{ include (print $.Template.BasePath "/event-bus-configmap.yaml") . | sha256sum }}
27+
{{- with .Values.chromeNode.annotations }}
28+
{{ toYaml . | nindent 8 }}
29+
{{- end }}
30+
spec:
31+
containers:
32+
- name: selenium-chrome-node
33+
{{- $imageTag := default .Values.global.seleniumGrid.nodesImageTag .Values.chromeNode.imageTag }}
34+
image: {{ printf "%s:%s" .Values.chromeNode.imageName $imageTag }}
35+
imagePullPolicy: {{ .Values.chromeNode.imagePullPolicy }}
36+
{{- with .Values.chromeNode.extraEnvironmentVariables }}
37+
env: {{- tpl (toYaml .) $ | nindent 12 }}
38+
{{- end }}
39+
envFrom:
40+
- configMapRef:
41+
name: {{ .Values.busConfigMap.name }}
42+
{{- if gt (len .Values.chromeNode.ports) 0 }}
43+
ports:
44+
{{- range .Values.chromeNode.ports }}
45+
- containerPort: {{ . }}
46+
protocol: TCP
47+
{{- end }}
48+
{{- end }}
49+
volumeMounts:
50+
- name: dshm
51+
mountPath: /dev/shm
52+
{{- with .Values.chromeNode.resources }}
53+
resources: {{- toYaml . | nindent 12 }}
54+
{{- end }}
55+
{{- with .Values.chromeNode.nodeSelector }}
56+
nodeSelector: {{- toYaml . | nindent 8 }}
57+
{{- end }}
58+
{{- with .Values.chromeNode.tolerations }}
59+
tolerations:
60+
{{ toYaml . | nindent 6 }}
61+
{{- end }}
62+
volumes:
63+
- name: dshm
64+
emptyDir:
65+
medium: Memory
66+
sizeLimit: {{ default "1Gi" .Values.chromeNode.dshmVolumeSizeLimit }}
67+
{{- end }}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{{- if and .Values.chromeNode.enabled .Values.chromeNode.service.enabled }}
2+
apiVersion: v1
3+
kind: Service
4+
metadata:
5+
name: {{ template "seleniumGrid.chromeNode.fullname" . }}
6+
namespace: {{ .Release.Namespace }}
7+
labels:
8+
name: selenium-chrome-node
9+
{{- include "seleniumGrid.commonLabels" . | nindent 4 }}
10+
{{- with .Values.chromeNode.service.annotations }}
11+
annotations:
12+
{{- toYaml . | nindent 4 }}
13+
{{- end }}
14+
spec:
15+
type: {{ .Values.chromeNode.service.type }}
16+
selector:
17+
app: selenium-chrome-node
18+
ports:
19+
- name: tcp-chrome
20+
protocol: TCP
21+
port: {{ .Values.chromeNode.seleniumServicePort }}
22+
targetPort: {{ .Values.chromeNode.seleniumPort }}
23+
{{- end }}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{{- if .Values.isolateComponents }}
2+
apiVersion: apps/v1
3+
kind: Deployment
4+
metadata:
5+
name: {{ template "seleniumGrid.distributor.fullname" . }}
6+
namespace: {{ .Release.Namespace }}
7+
labels: &distributor_labels
8+
app: selenium-distributor
9+
app.kubernetes.io/name: selenium-distributor
10+
{{- include "seleniumGrid.commonLabels" . | nindent 4 }}
11+
{{- with .Values.customLabels }}
12+
{{- toYaml . | nindent 4 }}
13+
{{- end }}
14+
spec:
15+
replicas: 1
16+
selector:
17+
matchLabels:
18+
app: selenium-distributor
19+
template:
20+
metadata:
21+
labels: *distributor_labels
22+
{{- with .Values.components.distributor.annotations }}
23+
annotations: {{- toYaml . | nindent 8 }}
24+
{{- end }}
25+
spec:
26+
containers:
27+
- name: selenium-distributor
28+
{{- $imageTag := default .Values.global.seleniumGrid.imageTag .Values.components.distributor.imageTag }}
29+
image: {{ printf "%s:%s" .Values.components.distributor.imageName $imageTag }}
30+
imagePullPolicy: {{ .Values.components.distributor.imagePullPolicy }}
31+
env:
32+
- name: SE_SESSIONS_MAP_HOST
33+
value: {{ template "seleniumGrid.sessionMap.fullname" . }}
34+
- name: SE_SESSIONS_MAP_PORT
35+
value: {{ .Values.components.sessionMap.port | quote }}
36+
- name: SE_SESSION_QUEUE_HOST
37+
value: {{ template "seleniumGrid.sessionQueue.fullname" . }}
38+
- name: SE_SESSION_QUEUE_PORT
39+
value: {{ .Values.components.sessionQueue.port | quote }}
40+
{{- with .Values.components.extraEnvironmentVariables }}
41+
{{- tpl (toYaml .) $ | nindent 12 }}
42+
{{- end }}
43+
envFrom:
44+
- configMapRef:
45+
name: {{ .Values.busConfigMap.name }}
46+
ports:
47+
- containerPort: {{ .Values.components.distributor.port }}
48+
protocol: TCP
49+
{{- with .Values.components.distributor.resources }}
50+
resources: {{- toYaml . | nindent 12 }}
51+
{{- end }}
52+
{{- with .Values.components.distributor.nodeSelector }}
53+
nodeSelector: {{- toYaml . | nindent 8 }}
54+
{{- end }}
55+
{{- with .Values.components.distributor.tolerations }}
56+
tolerations:
57+
{{ toYaml . | nindent 6 }}
58+
{{- end }}
59+
{{- end }}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{{- if .Values.isolateComponents }}
2+
apiVersion: v1
3+
kind: Service
4+
metadata:
5+
name: {{ template "seleniumGrid.distributor.fullname" . }}
6+
namespace: {{ .Release.Namespace }}
7+
labels:
8+
app: selenium-distributor
9+
{{- include "seleniumGrid.commonLabels" . | nindent 4 }}
10+
{{- with .Values.customLabels }}
11+
{{- toYaml . | nindent 4 }}
12+
{{- end }}
13+
{{- with .Values.components.distributor.serviceAnnotations }}
14+
annotations: {{- toYaml . | nindent 4 }}
15+
{{- end }}
16+
spec:
17+
selector:
18+
app: selenium-distributor
19+
type: {{ .Values.components.distributor.serviceType }}
20+
ports:
21+
- name: tcp-dist
22+
protocol: TCP
23+
port: {{ .Values.components.distributor.port }}
24+
targetPort: {{ .Values.components.distributor.port }}
25+
{{- end }}

0 commit comments

Comments
 (0)