Skip to content

Commit 56bca52

Browse files
authored
Add ingress resource, use ClusterIP by default (#1562)
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 [skip ci]
1 parent 745d65e commit 56bca52

File tree

6 files changed

+118
-10
lines changed

6 files changed

+118
-10
lines changed

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.4.0
6+
appVersion: 4.1.4-20220427
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{{- if .Values.ingress.enabled }}
2+
{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
3+
{{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }}
4+
{{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}}
5+
{{- end }}
6+
{{- end }}
7+
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
8+
apiVersion: networking.k8s.io/v1
9+
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
10+
apiVersion: networking.k8s.io/v1beta1
11+
{{- else -}}
12+
apiVersion: extensions/v1beta1
13+
{{- end }}
14+
kind: Ingress
15+
metadata:
16+
name: selenium-ingress
17+
labels:
18+
{{- include "seleniumGrid.commonLabels" . | nindent 4 }}
19+
{{- with .Values.customLabels }}
20+
{{- toYaml . | nindent 4 }}
21+
{{- end }}
22+
{{- with .Values.ingress.annotations }}
23+
annotations:
24+
{{- toYaml . | nindent 4 }}
25+
{{- end }}
26+
spec:
27+
{{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
28+
ingressClassName: {{ .Values.ingress.className }}
29+
{{- end }}
30+
{{- if .Values.ingress.tls }}
31+
tls:
32+
{{- range .Values.ingress.tls }}
33+
- hosts:
34+
{{- range .hosts }}
35+
- {{ . | quote }}
36+
{{- end }}
37+
secretName: {{ .secretName }}
38+
{{- end }}
39+
{{- end }}
40+
rules:
41+
{{- if $.Values.ingress.hostname }}
42+
- host: {{ .Values.ingress.hostname }}
43+
http:
44+
{{- else }}
45+
- http:
46+
{{- end }}
47+
paths:
48+
- path: /
49+
pathType: Prefix
50+
backend:
51+
service:
52+
{{- if $.Values.isolateComponents }}
53+
name: {{ template "seleniumGrid.router.fullname" $ }}
54+
port:
55+
number: {{ $.Values.components.router.port }}
56+
{{- else }}
57+
name: {{ template "seleniumGrid.hub.fullname" $ }}
58+
port:
59+
number: {{ $.Values.hub.port }}
60+
{{- end }}
61+
{{- end }}

charts/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.1
614

715
### Added

charts/selenium-grid/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ helm install selenium-grid docker-selenium/selenium-grid --set isolateComponents
2424

2525
# Or install specified version
2626
helm install selenium-grid docker-selenium/selenium-grid --version 0.3.1
27+
28+
# In both cases grid exposed by default using ingress. You may want to set hostname for the grid. Default hostname is selenium-grid.local.
29+
helm install selenium-grid --set ingress.hostname=selenium-grid.k8s.local docker-selenium/chart/selenium-grid/.
2730
```
2831

2932
## Updating Selenium-Grid release
@@ -57,6 +60,11 @@ This table contains the configuration parameters of the chart and their default
5760
| --------------------------------------- | ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
5861
| `isolateComponents` | `false` | Deploy Router, Distributor, EventBus, SessionMap and Nodes separately |
5962
| `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 |
63+
| `ingress.enabled` | `true` | Enable or disable ingress resource |
64+
| `ingress.className` | `""` | Name of ingress class to select which controller will implement ingress resource |
65+
| `ingress.annotations` | `{}` | Custom annotations for ingress resource |
66+
| `ingress.hostname` | `selenium-grid.local` | Default host for the ingress resource |
67+
| `ingress.tls` | `[]` | TLS backend configuration for ingress resource |
6068
| `busConfigMap.annotations` | `{}` | Custom annotations for configmap |
6169
| `chromeNode.enabled` | `true` | Enable chrome nodes |
6270
| `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 }}

charts/selenium-grid/values.yaml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,19 @@ 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+
# Name of ingress class to select which controller will implement ingress resource
16+
className: ""
17+
# Custom annotations for ingress resource
18+
annotations: {}
19+
# Default host for the ingress resource
20+
hostname: selenium-grid.local
21+
# TLS backend configuration for ingress resource
22+
tls: []
23+
1124
# ConfigMap that contains SE_EVENT_BUS_HOST, SE_EVENT_BUS_PUBLISH_PORT and SE_EVENT_BUS_SUBSCRIBE_PORT variables
1225
busConfigMap:
1326
# Name of the configmap
@@ -52,7 +65,7 @@ components:
5265
# Resources for router container
5366
resources: {}
5467
# Kubernetes service type (see https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types)
55-
serviceType: NodePort
68+
serviceType: ClusterIP
5669
# Custom annotations for router service
5770
serviceAnnotations: {}
5871
# Tolerations for router container
@@ -229,7 +242,7 @@ hub:
229242
# Resources for selenium-hub container
230243
resources: {}
231244
# Kubernetes service type (see https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types)
232-
serviceType: NodePort
245+
serviceType: ClusterIP
233246
# Custom annotations for Selenium Hub service
234247
serviceAnnotations: {}
235248
# Tolerations for selenium-hub container

0 commit comments

Comments
 (0)