Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ingress resource, use ClusterIP by default #1562

Merged
merged 1 commit into from
Jun 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.4.0
appVersion: 4.1.4-20220427
61 changes: 61 additions & 0 deletions chart/selenium-grid/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{{- if .Values.ingress.enabled }}
{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }}
{{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}}
{{- end }}
{{- end }}
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: selenium-ingress
labels:
{{- include "seleniumGrid.commonLabels" . | nindent 4 }}
{{- with .Values.customLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ .Values.ingress.className }}
{{- end }}
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- if $.Values.ingress.hostname }}
- host: {{ .Values.ingress.hostname }}
http:
{{- else }}
- http:
{{- end }}
paths:
- path: /
pathType: Prefix
backend:
service:
{{- if $.Values.isolateComponents }}
name: {{ template "seleniumGrid.router.fullname" $ }}
port:
number: {{ $.Values.components.router.port }}
{{- else }}
name: {{ template "seleniumGrid.hub.fullname" $ }}
port:
number: {{ $.Values.hub.port }}
{{- end }}
{{- end }}
8 changes: 8 additions & 0 deletions charts/selenium-grid/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

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

## :heavy_check_mark: 0.4.0

### Added
- Expose the Hub or the Router by default with ingress resource.

### Changed
- Set the default serviceType of the Hub and the Router to ClusterIP

## :heavy_check_mark: 0.3.1

### Added
Expand Down
8 changes: 8 additions & 0 deletions charts/selenium-grid/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ helm install selenium-grid docker-selenium/selenium-grid --set isolateComponents

# Or install specified version
helm install selenium-grid docker-selenium/selenium-grid --version 0.3.1

# In both cases grid exposed by default using ingress. You may want to set hostname for the grid. Default hostname is selenium-grid.local.
helm install selenium-grid --set ingress.hostname=selenium-grid.k8s.local docker-selenium/chart/selenium-grid/.
```

## Updating Selenium-Grid release
Expand Down Expand Up @@ -57,6 +60,11 @@ This table contains the configuration parameters of the chart and their default
| --------------------------------------- | ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
| `isolateComponents` | `false` | Deploy Router, Distributor, EventBus, SessionMap and Nodes separately |
| `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 |
| `ingress.enabled` | `true` | Enable or disable ingress resource |
| `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.tls` | `[]` | TLS backend configuration for ingress resource |
| `busConfigMap.annotations` | `{}` | Custom annotations for configmap |
| `chromeNode.enabled` | `true` | Enable chrome nodes |
| `chromeNode.replicas` | `1` | Number of chrome nodes |
Expand Down
28 changes: 20 additions & 8 deletions charts/selenium-grid/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
Selenium Grid Server deployed succesfully.
Selenium Grid Server deployed successfully.

{{- $svcName := ternary (include "seleniumGrid.router.fullname" . ) (include "seleniumGrid.hub.fullname" . ) .Values.isolateComponents }}
{{- $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 }}

1. To access Selenium from outside of Kubernetes, run 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 .Values.ingress.enabled }}
{{- if .Values.ingress.hostname }}
1. Ingress is enabled, and it exposes the Grid Hub or Grid Router with the hostname you supplied.
To access Selenium from outside of Kubernetes, simply open http://{{ .Values.ingress.hostname }}.
{{- else}}
1. Ingress is enabled, but hostname doesn't set. All inbound HTTP traffic will be routed to the Grid by matching any host.
Please keep in mind that it is rarely necessary, and in most cases, you shall provide `ingress.hostname` in values.yaml.
To access Selenium from outside of Kubernetes:
- open IP of the any node with Ingress, or
- any hostname pointing to the node with Ingress
{{- end}}
{{- else}}
1. Ingress is disabled. To access Selenium from outside of Kubernetes, simply run these commands:
{{- if contains "NodePort" $serviceType }}
export NODE_PORT=$(kubectl get -n {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" svc {{ $svcName }})
export NODE_IP=$(kubectl get nodes -n {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
Expand All @@ -22,6 +33,7 @@ Selenium Grid Server deployed succesfully.
echo "Point your WebDriver tests to {{ $localUrl | replace "PORT" (toString $port) }}"
kubectl -n {{ .Release.Namespace }} port-forward $POD_NAME {{ $port }}:{{ $port }}
{{- end }}
{{- end}}

2. Within Kubernetes cluster, you can use following Service endpoint:
2. Within Kubernetes cluster, you can use following Service endpoint:
http://{{ $svcName }}.{{ .Release.Namespace }}.svc:{{ $port }}
17 changes: 15 additions & 2 deletions charts/selenium-grid/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@ global:
# Deploy Router, Distributor, EventBus, SessionMap and Nodes separately
isolateComponents: false

# Configure the ingress resource to access the Grid installation.
ingress:
# Enable or disable ingress resource
enabled: true
# Name of ingress class to select which controller will implement ingress resource
className: ""
# Custom annotations for ingress resource
annotations: {}
# Default host for the ingress resource
hostname: selenium-grid.local
# TLS backend configuration for ingress resource
tls: []

# ConfigMap that contains SE_EVENT_BUS_HOST, SE_EVENT_BUS_PUBLISH_PORT and SE_EVENT_BUS_SUBSCRIBE_PORT variables
busConfigMap:
# Name of the configmap
Expand Down Expand Up @@ -52,7 +65,7 @@ components:
# Resources for router container
resources: {}
# Kubernetes service type (see https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types)
serviceType: NodePort
serviceType: ClusterIP
# Custom annotations for router service
serviceAnnotations: {}
# Tolerations for router container
Expand Down Expand Up @@ -229,7 +242,7 @@ hub:
# Resources for selenium-hub container
resources: {}
# Kubernetes service type (see https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types)
serviceType: NodePort
serviceType: ClusterIP
# Custom annotations for Selenium Hub service
serviceAnnotations: {}
# Tolerations for selenium-hub container
Expand Down