Skip to content

Commit

Permalink
Custom Ingress Path for Helm Chart (#1834)
Browse files Browse the repository at this point in the history
* Added ingress path option to helm values file

* Update README.md

* Update README.md

* Update README.md

* Update ingress.yaml

* Updated chart version

* Update Chart.yaml

* Add explicit SE_HUB_SUB_PATH environment variable for the HUB

* Add SE_SUB_PATH to recommended scripts and added documentation

* Added sub_path helm value for hub and components

* Removed sub_path from components that do not use it

---------

Co-authored-by: Diego Molina <[email protected]>
  • Loading branch information
JordanZimmitti and diemol authored May 11, 2023
1 parent 22355a7 commit 8019879
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 5 deletions.
6 changes: 6 additions & 0 deletions Hub/start-selenium-grid-hub.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ if [ ! -z "$SE_HUB_PORT" ]; then
PORT_CONFIG="--port ${SE_HUB_PORT}"
fi

if [ ! -z "$SE_SUB_PATH" ]; then
echo "Using SE_SUB_PATH: ${SE_SUB_PATH}"
SUB_PATH_CONFIG="--sub-path ${SE_SUB_PATH}"
fi

EXTRA_LIBS="/opt/selenium/selenium-http-jdk-client.jar"

if [ ! -z "$SE_ENABLE_TRACING" ]; then
Expand All @@ -39,4 +44,5 @@ java ${JAVA_OPTS:-$SE_JAVA_OPTS} -Dwebdriver.http.factory=jdk-http-client \
--config /opt/selenium/config.toml \
${HOST_CONFIG} \
${PORT_CONFIG} \
${SUB_PATH_CONFIG} \
${SE_OPTS}
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Talk to us at https://www.selenium.dev/support/
+ [SE_OPTS Selenium Configuration Options](#se_opts-selenium-configuration-options)
+ [SE_JAVA_OPTS Java Environment Options](#se_java_opts-java-environment-options)
+ [Node configuration options](#node-configuration-options)
+ [Setting Sub Path](#setting-sub-path)
+ [Setting Screen Resolution](#setting-screen-resolution)
+ [Grid Url and Session Timeout](#grid-url-and-session-timeout)
+ [Session request timeout](#session-request-timeout)
Expand Down Expand Up @@ -793,6 +794,15 @@ $ docker run -d \
--shm-size="2g" selenium/node-chrome:4.9.1-20230508
```

### Setting Sub Path

By default, Selenium is reachable at `http://127.0.0.1:4444/`. Selenium can be configured to use a custom sub path by specifying the `SE_SUB_PATH`
environmental variable. In the example below Selenium is reachable at `http://127.0.0.1:4444/selenium-grid/`

```bash
$ docker run -d -p 4444:4444 -e SE_SUB_PATH=/selenium-grid/ --name selenium-hub selenium/hub:4.9.0-20230421
```

### Setting Screen Resolution

By default, nodes start with a screen resolution of 1360 x 1020 with a color depth of 24 bits and a dpi of 96.
Expand Down
6 changes: 6 additions & 0 deletions Router/start-selenium-grid-router.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ if [[ -z "${SE_SESSION_QUEUE_PORT}" ]]; then
exit 1
fi

if [ ! -z "$SE_SUB_PATH" ]; then
echo "Using SE_SUB_PATH: ${SE_SUB_PATH}"
SUB_PATH_CONFIG="--sub-path ${SE_SUB_PATH}"
fi

if [ ! -z "$SE_OPTS" ]; then
echo "Appending Selenium options: ${SE_OPTS}"
fi
Expand Down Expand Up @@ -72,4 +77,5 @@ java ${JAVA_OPTS:-$SE_JAVA_OPTS} -Dwebdriver.http.factory=jdk-http-client \
--bind-host ${SE_BIND_HOST} \
${HOST_CONFIG} \
${PORT_CONFIG} \
${SUB_PATH_CONFIG} \
${SE_OPTS}
6 changes: 6 additions & 0 deletions Standalone/start-selenium-standalone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
#
# IMPORTANT: Change this file only in directory Standalone!

if [ ! -z "$SE_SUB_PATH" ]; then
echo "Using SE_SUB_PATH: ${SE_SUB_PATH}"
SUB_PATH_CONFIG="--sub-path ${SE_SUB_PATH}"
fi

if [ ! -z "$SE_OPTS" ]; then
echo "Appending Selenium options: ${SE_OPTS}"
fi
Expand All @@ -28,4 +33,5 @@ java ${JAVA_OPTS:-$SE_JAVA_OPTS} -Dwebdriver.http.factory=jdk-http-client \
--ext ${EXTRA_LIBS} standalone \
--bind-host ${SE_BIND_HOST} \
--config /opt/selenium/config.toml \
${SUB_PATH_CONFIG} \
${SE_OPTS}
2 changes: 1 addition & 1 deletion charts/selenium-grid/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ apiVersion: v2
name: selenium-grid
description: A Helm chart for creating a Selenium Grid Server in Kubernetes
type: application
version: 0.15.8
version: 0.16.0
appVersion: 4.9.0-20230421
icon: https://github.com/SeleniumHQ/docker-selenium/raw/trunk/logo.png
3 changes: 3 additions & 0 deletions charts/selenium-grid/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ This table contains the configuration parameters of the chart and their default
| `ingress.className` | `""` | Name of ingress class to select which controller will implement ingress resource |
| `ingress.annotations` | `{}` | Custom annotations for ingress resource |
| `ingress.hostname` | `selenium-grid.local` | Default host for the ingress resource |
| `ingress.path` | `/` | Default host path for the ingress resource |
| `ingress.tls` | `[]` | TLS backend configuration for ingress resource |
| `busConfigMap.annotations` | `{}` | Custom annotations for configmap |
| `chromeNode.enabled` | `true` | Enable chrome nodes |
Expand Down Expand Up @@ -174,6 +175,7 @@ You can configure the Selenium Hub with this values:
| `hub.tolerations` | `[]` | Tolerations for selenium-hub pods |
| `hub.nodeSelector` | `{}` | Node Selector for selenium-hub pods |
| `hub.priorityClassName` | `""` | Priority class name for selenium-hub pods |
| `hub.subPath` | `/` | Custom sub path for the hub deployment |
| `hub.extraEnvironmentVariables` | `nil` | Custom environment variables for selenium-hub |
| `hub.extraEnvFrom` | `nil` | Custom environment variables for selenium taken from `configMap` or `secret`-hub |
| `hub.resources` | `{}` | Resources for selenium-hub container |
Expand Down Expand Up @@ -252,6 +254,7 @@ If you implement selenium-grid with separate components (`isolateComponents: tru
| `components.sessionQueue.tolerations` | `[]` | Tolerations for Session Queue pods |
| `components.sessionQueue.nodeSelector` | `{}` | Node Selector for Session Queue pods |
| `components.sessionQueue.priorityClassName` | `""` | Priority class name for Session Queue pods |
| `components.subPath` | `/` | Custom sub path for all components |
| `components.extraEnvironmentVariables` | `nil` | Custom environment variables for all components |
| `components.extraEnvFrom` | `nil` | Custom environment variables taken from `configMap` or `secret` for all components |

Expand Down
9 changes: 6 additions & 3 deletions charts/selenium-grid/templates/hub-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,12 @@ spec:
successThreshold: {{ .Values.hub.readinessProbe.successThreshold }}
failureThreshold: {{ .Values.hub.readinessProbe.failureThreshold }}
{{- end }}
{{- with .Values.hub.extraEnvironmentVariables }}
env: {{- tpl (toYaml .) $ | nindent 12 }}
{{- end }}
env:
- name: SE_SUB_PATH
value: {{ .Values.hub.subPath }}
{{- with .Values.hub.extraEnvironmentVariables }}
{{- tpl (toYaml .) $ | nindent 12 }}
{{- end }}
{{- with .Values.hub.extraEnvFrom }}
envFrom:
{{- toYaml . | nindent 12 }}
Expand Down
2 changes: 1 addition & 1 deletion charts/selenium-grid/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ spec:
{{- end }}
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.Version }}
paths:
- path: /
- path: {{ $.Values.ingress.path | default "/" }}
pathType: Prefix
backend:
service:
Expand Down
2 changes: 2 additions & 0 deletions charts/selenium-grid/templates/router-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ spec:
value: {{ template "seleniumGrid.sessionQueue.fullname" . }}
- name: SE_SESSION_QUEUE_PORT
value: {{ .Values.components.sessionQueue.port | quote }}
- name: SE_SUB_PATH
value: {{ .Values.components.subPath }}
{{- with .Values.components.extraEnvironmentVariables }}
{{- tpl (toYaml .) $ | nindent 12 }}
{{- end }}
Expand Down
7 changes: 7 additions & 0 deletions charts/selenium-grid/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ ingress:
annotations: {}
# Default host for the ingress resource
hostname: selenium-grid.local
# Default host path for the ingress resource
path: /
# TLS backend configuration for ingress resource
tls: []

Expand Down Expand Up @@ -200,6 +202,9 @@ components:
# Priority class name for Session Queue pods
priorityClassName: ""

# Custom sub path for all components
subPath: /

# Custom environment variables for all components
extraEnvironmentVariables:
# - name: SE_JAVA_OPTS
Expand Down Expand Up @@ -256,6 +261,8 @@ hub:
timeoutSeconds: 10
periodSeconds: 10
successThreshold: 1
# Custom sub path for the hub deployment
subPath: /
# Custom environment variables for selenium-hub
extraEnvironmentVariables:
# - name: SE_JAVA_OPTS
Expand Down

0 comments on commit 8019879

Please sign in to comment.