Skip to content

Commit

Permalink
Selenium Grid Helm Chart (#1508)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
3 people authored Feb 24, 2022
1 parent 6550263 commit fe28e0c
Show file tree
Hide file tree
Showing 26 changed files with 1,562 additions and 0 deletions.
23 changes: 23 additions & 0 deletions chart/selenium-grid/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
38 changes: 38 additions & 0 deletions chart/selenium-grid/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Change Log

All notable changes to this helm chart will be documented in this file.

## :heavy_check_mark: 0.3.0

### Added
- Support for Edge nodes.
- Support for `nodeSelector`.
- Support for `tolerations`.
- Allow to add additional labels to the hub, edge, firefox and chrome nodes.
- Fix queue component name (#1290)

### Changed
- Update image tag to 4.1.2-20220217

### Removed
- Opera nodes

## :heavy_check_mark: 0.2.0

### Added
- `CHANGELOG.md`

### Changed
- Added `global` block to be able to specify component's image tag globally.
- DSHM's volume size customizable.
- Service type and service annotations are now customizable.

### Fixed
- Services won't be created if nodes are disabled.

## :heavy_check_mark: 0.1.0

### Added
- Selenium grid components separated.
- Selenium Hub server.
- Chrome, Opera and Firefox nodes.
6 changes: 6 additions & 0 deletions chart/selenium-grid/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v2
name: selenium-grid
description: A Helm chart for creating a Selenium grid server in Kubernetes
type: application
version: 0.3.0
appVersion: 4.1.2-20220217
183 changes: 183 additions & 0 deletions chart/selenium-grid/README.md

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions chart/selenium-grid/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Selenium Grid Server deployed succesfully.

1. Get the URL FOR WebDriver tests by running these commands:

{{- $appName := ternary "selenium-router" "selenium-hub" .Values.isolateComponents }}
{{- $serviceType := ternary .Values.components.router.serviceType .Values.hub.serviceType .Values.isolateComponents }}
{{- $port := ternary .Values.components.router.port .Values.hub.port .Values.isolateComponents }}
{{- $localUrl := ternary "http://localhost:PORT" "http://localhost:PORT/wd/hub" .Values.isolateComponents }}
{{- if contains "NodePort" $serviceType }}
export NODE_PORT=$(kubectl get -n {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" svc {{ include "seleniumGrid.router.fullname" . }})
export NODE_IP=$(kubectl get nodes -n {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" $serviceType }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get -n {{ .Release.Namespace }} svc -w {{ include "seleniumGrid.router.fullname" . }}'
export SERVICE_IP=$(kubectl get svc -n {{ .Release.Namespace }} {{ include "seleniumGrid.router.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ $port }}
{{- else if contains "ClusterIP" $serviceType }}
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}")
echo "Point your WebDriver tests to {{ $localUrl | replace "PORT" (toString $port) }}"
kubectl -n {{ .Release.Namespace }} port-forward $POD_NAME {{ $port }}:{{ $port }}
{{- end }}
73 changes: 73 additions & 0 deletions chart/selenium-grid/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{{/*
Common labels
*/}}
{{- define "seleniumGrid.commonLabels" -}}
app.kubernetes.io/managed-by: {{ .Release.Service | lower }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/version: {{ .Chart.AppVersion }}
app.kubernetes.io/component: {{ printf "selenium-grid-%s" .Chart.AppVersion }}
helm.sh/chart: {{ printf "%s-%s" .Chart.Name (.Chart.Version | replace "+" "_") }}
{{- end -}}

{{/*
Selenium Hub fullname
*/}}
{{- define "seleniumGrid.hub.fullname" -}}
{{- default "selenium-hub" .Values.hub.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Event bus fullname
*/}}
{{- define "seleniumGrid.eventBus.fullname" -}}
{{- default "selenium-event-bus" .Values.components.eventBus.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Router fullname
*/}}
{{- define "seleniumGrid.router.fullname" -}}
{{- default "selenium-router" .Values.components.router.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Distributor fullname
*/}}
{{- define "seleniumGrid.distributor.fullname" -}}
{{- default "selenium-distributor" .Values.components.distributor.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
SessionMap fullname
*/}}
{{- define "seleniumGrid.sessionMap.fullname" -}}
{{- default "selenium-session-map" .Values.components.sessionMap.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
SessionQueue fullname
*/}}
{{- define "seleniumGrid.sessionQueue.fullname" -}}
{{- default "selenium-session-queue" .Values.components.sessionQueue.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Chrome node fullname
*/}}
{{- define "seleniumGrid.chromeNode.fullname" -}}
{{- default "selenium-chrome-node" .Values.chromeNode.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Firefox node fullname
*/}}
{{- define "seleniumGrid.firefoxNode.fullname" -}}
{{- default "selenium-firefox-node" .Values.firefoxNode.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Edge node fullname
*/}}
{{- define "seleniumGrid.edgeNode.fullname" -}}
{{- default "selenium-edge-node" .Values.edgeNode.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}
67 changes: 67 additions & 0 deletions chart/selenium-grid/templates/chrome-node-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{{- if .Values.chromeNode.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "seleniumGrid.chromeNode.fullname" . }}
namespace: {{ .Release.Namespace }}
labels: &chrome_node_labels
app: selenium-chrome-node
app.kubernetes.io/name: selenium-chrome-node
{{- include "seleniumGrid.commonLabels" . | nindent 4 }}
{{- with .Values.chromeNode.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.customLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
replicas: {{ .Values.chromeNode.replicas }}
selector:
matchLabels:
app: selenium-chrome-node
template:
metadata:
labels: *chrome_node_labels
annotations:
checksum/event-bus-configmap: {{ include (print $.Template.BasePath "/event-bus-configmap.yaml") . | sha256sum }}
{{- with .Values.chromeNode.annotations }}
{{ toYaml . | nindent 8 }}
{{- end }}
spec:
containers:
- name: selenium-chrome-node
{{- $imageTag := default .Values.global.seleniumGrid.nodesImageTag .Values.chromeNode.imageTag }}
image: {{ printf "%s:%s" .Values.chromeNode.imageName $imageTag }}
imagePullPolicy: {{ .Values.chromeNode.imagePullPolicy }}
{{- with .Values.chromeNode.extraEnvironmentVariables }}
env: {{- tpl (toYaml .) $ | nindent 12 }}
{{- end }}
envFrom:
- configMapRef:
name: {{ .Values.busConfigMap.name }}
{{- if gt (len .Values.chromeNode.ports) 0 }}
ports:
{{- range .Values.chromeNode.ports }}
- containerPort: {{ . }}
protocol: TCP
{{- end }}
{{- end }}
volumeMounts:
- name: dshm
mountPath: /dev/shm
{{- with .Values.chromeNode.resources }}
resources: {{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.chromeNode.nodeSelector }}
nodeSelector: {{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.chromeNode.tolerations }}
tolerations:
{{ toYaml . | nindent 6 }}
{{- end }}
volumes:
- name: dshm
emptyDir:
medium: Memory
sizeLimit: {{ default "1Gi" .Values.chromeNode.dshmVolumeSizeLimit }}
{{- end }}
23 changes: 23 additions & 0 deletions chart/selenium-grid/templates/chrome-node-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{{- if and .Values.chromeNode.enabled .Values.chromeNode.service.enabled }}
apiVersion: v1
kind: Service
metadata:
name: {{ template "seleniumGrid.chromeNode.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
name: selenium-chrome-node
{{- include "seleniumGrid.commonLabels" . | nindent 4 }}
{{- with .Values.chromeNode.service.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
type: {{ .Values.chromeNode.service.type }}
selector:
app: selenium-chrome-node
ports:
- name: tcp-chrome
protocol: TCP
port: {{ .Values.chromeNode.seleniumServicePort }}
targetPort: {{ .Values.chromeNode.seleniumPort }}
{{- end }}
59 changes: 59 additions & 0 deletions chart/selenium-grid/templates/distributor-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{{- if .Values.isolateComponents }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "seleniumGrid.distributor.fullname" . }}
namespace: {{ .Release.Namespace }}
labels: &distributor_labels
app: selenium-distributor
app.kubernetes.io/name: selenium-distributor
{{- include "seleniumGrid.commonLabels" . | nindent 4 }}
{{- with .Values.customLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
replicas: 1
selector:
matchLabels:
app: selenium-distributor
template:
metadata:
labels: *distributor_labels
{{- with .Values.components.distributor.annotations }}
annotations: {{- toYaml . | nindent 8 }}
{{- end }}
spec:
containers:
- name: selenium-distributor
{{- $imageTag := default .Values.global.seleniumGrid.imageTag .Values.components.distributor.imageTag }}
image: {{ printf "%s:%s" .Values.components.distributor.imageName $imageTag }}
imagePullPolicy: {{ .Values.components.distributor.imagePullPolicy }}
env:
- name: SE_SESSIONS_MAP_HOST
value: {{ template "seleniumGrid.sessionMap.fullname" . }}
- name: SE_SESSIONS_MAP_PORT
value: {{ .Values.components.sessionMap.port | quote }}
- name: SE_SESSION_QUEUE_HOST
value: {{ template "seleniumGrid.sessionQueue.fullname" . }}
- name: SE_SESSION_QUEUE_PORT
value: {{ .Values.components.sessionQueue.port | quote }}
{{- with .Values.components.extraEnvironmentVariables }}
{{- tpl (toYaml .) $ | nindent 12 }}
{{- end }}
envFrom:
- configMapRef:
name: {{ .Values.busConfigMap.name }}
ports:
- containerPort: {{ .Values.components.distributor.port }}
protocol: TCP
{{- with .Values.components.distributor.resources }}
resources: {{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.components.distributor.nodeSelector }}
nodeSelector: {{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.components.distributor.tolerations }}
tolerations:
{{ toYaml . | nindent 6 }}
{{- end }}
{{- end }}
25 changes: 25 additions & 0 deletions chart/selenium-grid/templates/distributor-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{{- if .Values.isolateComponents }}
apiVersion: v1
kind: Service
metadata:
name: {{ template "seleniumGrid.distributor.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
app: selenium-distributor
{{- include "seleniumGrid.commonLabels" . | nindent 4 }}
{{- with .Values.customLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.components.distributor.serviceAnnotations }}
annotations: {{- toYaml . | nindent 4 }}
{{- end }}
spec:
selector:
app: selenium-distributor
type: {{ .Values.components.distributor.serviceType }}
ports:
- name: tcp-dist
protocol: TCP
port: {{ .Values.components.distributor.port }}
targetPort: {{ .Values.components.distributor.port }}
{{- end }}
Loading

0 comments on commit fe28e0c

Please sign in to comment.