Skip to content

Commit 36d06b4

Browse files
committed
Add ingress resource, use ClusterIP by default
Set ClusterIP service type for Hub and Router components, NodePort could be set explicitly, but the default is ClusterIP. Add enabled by default ingress resource, which exposes either Hub or Router service. In the case of LoadBalancer or NodePort set explicitly, you shall turn off ingress explicitly as well. To turn off: --set ingress.enabled=false End-user shall supply the hostname for the ingress. There is an option to use an empty host instead. Be aware of the consequences of accepting traffic from all hosts. Fixes #1546
1 parent 0a5c397 commit 36d06b4

File tree

6 files changed

+80
-11
lines changed

6 files changed

+80
-11
lines changed

chart/selenium-grid/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

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

5+
## :heavy_check_mark: 0.4.0
6+
7+
### Added
8+
- Expose the Hub or the Router by default with ingress resource.
9+
10+
### Changed
11+
- Set the default serviceType of the Hub and the Router to ClusterIP
12+
513
## :heavy_check_mark: 0.3.0
614

715
### Added

chart/selenium-grid/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ apiVersion: v2
22
name: selenium-grid
33
description: A Helm chart for creating a Selenium grid server in Kubernetes
44
type: application
5-
version: 0.3.0
5+
version: 0.4.0
66
appVersion: 4.1.4-20220427

chart/selenium-grid/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ helm install selenium-grid docker-selenium/chart/selenium-grid/.
1515

1616
# Or install full grid (Router, Distributor, EventBus, SessionMap and SessionQueue components separated)
1717
helm install selenium-grid --set isolateComponents=true docker-selenium/chart/selenium-grid/.
18+
19+
# In both cases grid exposed by default using ingress. You may want to set hostname for the grid. Default hostname is selenium-grid.local.
20+
helm install selenium-grid --set ingress.hostname=selenium-grid.k8s.local docker-selenium/chart/selenium-grid/.
1821
```
1922

2023
## Updating Selenium-Grid release
@@ -48,6 +51,8 @@ This table contains the configuration parameters of the chart and their default
4851
| --------------------------------------- | ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
4952
| `isolateComponents` | `false` | Deploy Router, Distributor, EventBus, SessionMap and Nodes separately |
5053
| `busConfigMap.name` | `selenium-event-bus-config` | Name of the configmap that contains SE_EVENT_BUS_HOST, SE_EVENT_BUS_PUBLISH_PORT and SE_EVENT_BUS_SUBSCRIBE_PORT variables |
54+
| `ingress.enabled` | `true` | Enable or disable ingress resource |
55+
| `ingress.hostname` | `selenium-grid.local` | Default host for the ingress resource |
5156
| `busConfigMap.annotations` | `{}` | Custom annotations for configmap |
5257
| `chromeNode.enabled` | `true` | Enable chrome nodes |
5358
| `chromeNode.replicas` | `1` | Number of chrome nodes |
Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
1-
Selenium Grid Server deployed succesfully.
1+
Selenium Grid Server deployed successfully.
22

33
{{- $svcName := ternary (include "seleniumGrid.router.fullname" . ) (include "seleniumGrid.hub.fullname" . ) .Values.isolateComponents }}
4+
{{- $appName := ternary "selenium-router" "selenium-hub" .Values.isolateComponents }}
5+
{{- $serviceType := ternary .Values.components.router.serviceType .Values.hub.serviceType .Values.isolateComponents }}
6+
{{- $port := ternary .Values.components.router.port .Values.hub.port .Values.isolateComponents }}
7+
{{- $localUrl := ternary "http://localhost:PORT" "http://localhost:PORT/wd/hub" .Values.isolateComponents }}
48

5-
1. To access Selenium from outside of Kubernetes, run these commands:
6-
7-
{{- $appName := ternary "selenium-router" "selenium-hub" .Values.isolateComponents }}
8-
{{- $serviceType := ternary .Values.components.router.serviceType .Values.hub.serviceType .Values.isolateComponents }}
9-
{{- $port := ternary .Values.components.router.port .Values.hub.port .Values.isolateComponents }}
10-
{{- $localUrl := ternary "http://localhost:PORT" "http://localhost:PORT/wd/hub" .Values.isolateComponents }}
9+
{{- if .Values.ingress.enabled }}
10+
{{- if .Values.ingress.hostname }}
11+
1. Ingress is enabled, and it exposes the Grid Hub or Grid Router with the hostname you supplied.
12+
To access Selenium from outside of Kubernetes, simply open http://{{ .Values.ingress.hostname }}.
13+
{{- else}}
14+
1. Ingress is enabled, but hostname doesn't set. All inbound HTTP traffic will be routed to the Grid by matching any host.
15+
Please keep in mind that it is rarely necessary, and in most cases, you shall provide `ingress.hostname` in values.yaml.
16+
To access Selenium from outside of Kubernetes:
17+
- open IP of the any node with Ingress, or
18+
- any hostname pointing to the node with Ingress
19+
{{- end}}
20+
{{- else}}
21+
1. Ingress is disabled. To access Selenium from outside of Kubernetes, simply run these commands:
1122
{{- if contains "NodePort" $serviceType }}
1223
export NODE_PORT=$(kubectl get -n {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" svc {{ $svcName }})
1324
export NODE_IP=$(kubectl get nodes -n {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
@@ -22,6 +33,7 @@ Selenium Grid Server deployed succesfully.
2233
echo "Point your WebDriver tests to {{ $localUrl | replace "PORT" (toString $port) }}"
2334
kubectl -n {{ .Release.Namespace }} port-forward $POD_NAME {{ $port }}:{{ $port }}
2435
{{- end }}
36+
{{- end}}
2537

26-
2. Within Kubernetes cluster, you can use following Service endpoint:
38+
2. Within Kubernetes cluster, you can use following Service endpoint:
2739
http://{{ $svcName }}.{{ .Release.Namespace }}.svc:{{ $port }}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{{- if .Values.ingress.enabled }}
2+
apiVersion: networking.k8s.io/v1
3+
kind: Ingress
4+
metadata:
5+
name: selenium-ingress
6+
{{- with .Values.ingress.annotations }}
7+
annotations:
8+
{{- toYaml . | nindent 4 }}
9+
{{- end }}
10+
labels:
11+
{{- include "seleniumGrid.commonLabels" . | nindent 4 }}
12+
{{- with .Values.customLabels }}
13+
{{- toYaml . | nindent 4 }}
14+
{{- end }}
15+
spec:
16+
rules:
17+
{{- if $.Values.ingress.hostname }}
18+
- host: {{ .Values.ingress.hostname }}
19+
http:
20+
{{- else }}
21+
- http:
22+
{{- end }}
23+
paths:
24+
- path: /
25+
pathType: Prefix
26+
backend:
27+
service:
28+
{{- if $.Values.isolateComponents }}
29+
name: {{ template "seleniumGrid.router.fullname" $ }}
30+
port:
31+
number: {{ $.Values.components.router.port }}
32+
{{- else }}
33+
name: {{ template "seleniumGrid.hub.fullname" $ }}
34+
port:
35+
number: {{ $.Values.hub.port }}
36+
{{- end }}
37+
{{- end }}

chart/selenium-grid/values.yaml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ global:
88
# Deploy Router, Distributor, EventBus, SessionMap and Nodes separately
99
isolateComponents: false
1010

11+
# Configure the ingress resource to access the Grid installation.
12+
ingress:
13+
# Enable or disable ingress resource
14+
enabled: true
15+
# Default host for the ingress resource
16+
hostname: selenium-grid.local
17+
1118
# ConfigMap that contains SE_EVENT_BUS_HOST, SE_EVENT_BUS_PUBLISH_PORT and SE_EVENT_BUS_SUBSCRIBE_PORT variables
1219
busConfigMap:
1320
# Name of the configmap
@@ -52,7 +59,7 @@ components:
5259
# Resources for router container
5360
resources: {}
5461
# Kubernetes service type (see https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types)
55-
serviceType: NodePort
62+
serviceType: ClusterIP
5663
# Custom annotations for router service
5764
serviceAnnotations: {}
5865
# Tolerations for router container
@@ -229,7 +236,7 @@ hub:
229236
# Resources for selenium-hub container
230237
resources: {}
231238
# Kubernetes service type (see https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types)
232-
serviceType: NodePort
239+
serviceType: ClusterIP
233240
# Custom annotations for Selenium Hub service
234241
serviceAnnotations: {}
235242
# Tolerations for selenium-hub container

0 commit comments

Comments
 (0)