Skip to content

Commit e15df42

Browse files
authored
chart(breaking change): enable TLS and default annotations for ingress (#2326)
docs for #2321 Signed-off-by: Viet Nguyen Duc <[email protected]>
1 parent b4327c2 commit e15df42

File tree

10 files changed

+109
-51
lines changed

10 files changed

+109
-51
lines changed

Diff for: .github/workflows/build-test.yml

+6
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ permissions: write-all
2626

2727
env:
2828
GH_CLI_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29+
GH_CLI_TOKEN_PR: ${{ secrets.SELENIUM_CI_TOKEN || secrets.GITHUB_TOKEN }}
2930
RUN_ID: ${{ github.run_id }}
3031
RERUN_FAILED_ONLY: ${{ github.event.inputs.rerunFailedOnly || true }}
3132
RUN_ATTEMPT: ${{ github.run_attempt }}
@@ -57,7 +58,12 @@ jobs:
5758
run: |
5859
sudo apt update
5960
sudo apt install gh
61+
- name: Authenticate GitHub CLI for PR
62+
if: github.event_name == 'pull_request'
63+
run: |
64+
echo "$GH_CLI_TOKEN_PR" | gh auth login --with-token
6065
- name: Authenticate GitHub CLI
66+
if: github.event_name != 'pull_request'
6167
run: |
6268
echo "$GH_CLI_TOKEN" | gh auth login --with-token
6369
- name: Rerun workflow when failure

Diff for: Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@ chart_test_autoscaling_job_hostname:
798798

799799
chart_test_autoscaling_job:
800800
PLATFORMS=$(PLATFORMS) TEST_CHROMIUM=true RELEASE_NAME=selenium CHART_ENABLE_TRACING=true CHART_FULL_DISTRIBUTED_MODE=true \
801-
SECURE_INGRESS_ONLY_GENERATE=true CHART_ENABLE_INGRESS_HOSTNAME=true SELENIUM_GRID_PROTOCOL=https SELENIUM_GRID_HOST=selenium-grid.prod SUB_PATH=/ SELENIUM_GRID_PORT=443 \
801+
SECURE_INGRESS_ONLY_CONFIG_INLINE=true SECURE_USE_EXTERNAL_CERT=true CHART_ENABLE_INGRESS_HOSTNAME=true SELENIUM_GRID_PROTOCOL=https SELENIUM_GRID_HOST=selenium-grid.prod SUB_PATH=/ SELENIUM_GRID_PORT=443 \
802802
VERSION=$(TAG_VERSION) VIDEO_TAG=$(FFMPEG_TAG_VERSION)-$(BUILD_DATE) NAMESPACE=$(NAMESPACE) BINDING_VERSION=$(BINDING_VERSION) \
803803
./tests/charts/make/chart_test.sh JobAutoscaling
804804

Diff for: charts/selenium-grid/README.md

+48-29
Original file line numberDiff line numberDiff line change
@@ -281,25 +281,23 @@ nginx.ingress.kubernetes.io/client-body-buffer-size
281281

282282
# `ingress.nginx.proxyBuffer.number` pass value to annotation(s)
283283
nginx.ingress.kubernetes.io/proxy-buffers-number
284-
```
285-
286-
You can generate a test double self-signed certificate specify for your `hostname`, assign it to spec `ingress.tls` and NGINX ingress controller default certificate (if it is enabled inline). For example:
287284

288-
```yaml
289-
tls:
290-
ingress:
291-
generateTLS: true
285+
# `ingress.nginx.websocket` pass boolean value to add backend service has WebSocket request (Hub/Router - noVNC, CDP, etc.)
286+
nginx.org/websocket-services: "{{ template ($.Values.isolateComponents | ternary "seleniumGrid.router.fullname" "seleniumGrid.hub.fullname") $ }}"
292287

293-
ingress:
294-
hostname: "your.domain.com"
288+
# `ingress.nginx.sslPassthrough` pass boolean value to enable SSL Passthrough (when secure connection is enabled in Grid server backend)
289+
nginx.ingress.kubernetes.io/ssl-passthrough: "true"
290+
nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
295291

296-
ingress-nginx:
297-
enabled: true
298-
controller:
299-
extraArgs:
300-
default-ssl-certificate: '$(POD_NAMESPACE)/selenium-tls-secret'
292+
# `ingress.nginx.sslSecret` to specify a Secret with the certificate `tls.crt`, key `tls.key`, the name in the form "namespace/secretName"
293+
# By default, it is empty, the chart will use internal TLS secret resource (or the first `secretName` under `ingress.tls` if set)
294+
nginx.ingress.kubernetes.io/proxy-ssl-secret: {{ template "seleniumGrid.tls.fullname" $ }}
301295
```
302296
297+
Refer to [NGINX Ingress Controller Annotations](https://github.com/kubernetes/ingress-nginx/blob/main/docs/user-guide/nginx-configuration/annotations.md) for more details.
298+
299+
Refer to below section [Configuration of Secure Communication] for more details on how to configure secure communication to Ingress proxy.
300+
303301
## Configuration
304302
305303
### Configuration global
@@ -656,7 +654,7 @@ There are multiple ways to insert your certificate, private key, truststore to t
656654
```bash
657655
# Steps to prepare your self-signed certificate
658656
./certs/cert.sh -d /path/to/your/
659-
# Create TLS Secret with your certificate, private key, truststore
657+
# Create TLS Secret with your certificate, private key, truststore (or a Secret type kubernetes.io/tls)
660658
kubectl create secret generic -n $NAMESPACE my-external-tls-secret \
661659
--from-file=tls.crt=/path/to/your/tls.crt \
662660
--from-file=tls.key=/path/to/your/tls.key \
@@ -688,18 +686,16 @@ tls:
688686
```
689687

690688
In additional, if the ingress is enabled, and approach SSL Passthrough is used to ensure the request forwards to the backend components via an encrypted connection.
691-
With `ingress.hostname` is set, the default server TLS secret is also used for hosts TLS secretName when `ingress.tls` is empty. Once you specify `ingress.tls`, your specified secret will be used for hosts TLS secretName.
689+
With `ingress.hostname` is set, the default server TLS secret is also used for hosts TLS secretName when `ingress.tls` is empty. Once you specify `ingress.tls`, your specified secret will be used for hosts TLS secretName. For example
692690

693691
![SeleniumGrid_TLS_SSL-Passthrough](./images/SeleniumGrid_TLS_SSL-Passthrough.png)
694692

695-
Moreover, when sub-chart `ingress-nginx` is enabled (deploy Ingress NGINX Controller together), the default server TLS secret can also be assigned via `ingress-nginx.controller.extraArgs.default-ssl-certificate`.
696-
For example (replace `$RELEASENAME` and `$NAMESPACE` with your values):
693+
```yaml
694+
tls:
695+
enabled: true
697696
698-
```bash
699-
helm upgrade -i $RELEASENAME -n $NAMESPACE docker-selenium/selenium-grid \
700-
--set tls.enabled=true \
701-
--set ingress-nginx.enabled=true \
702-
--set ingress-nginx.controller.extraArgs.default-ssl-certificate=$NAMESPACE/$RELEASENAME-selenium-tls-secret
697+
ingress-ngnix:
698+
enabled: true
703699
```
704700

705701
Below is an example of Grid UI accessible via NodePort with secure connection, and using external TLS Secret (replace `$RELEASENAME` and `$NAMESPACE` with your values):
@@ -729,7 +725,7 @@ tls:
729725

730726
![SeleniumGrid_TLS_SSL-Termination](./images/SeleniumGrid_TLS_SSL-Termination.png)
731727

732-
In additional, a self-signed certificate and private key can be generated runtime during the chart deployment for Ingress TLS by setting these values (replace `$RELEASENAME` with your value):
728+
In additional, a self-signed certificate and private key can be generated runtime during the chart deployment for Ingress TLS by setting these values:
733729

734730
```yaml
735731
tls:
@@ -747,9 +743,6 @@ tls:
747743
748744
ingress-ngnix:
749745
enabled: true
750-
controller:
751-
extraArgs:
752-
default-ssl-certificate: $(POD_NAMESPACE)/$RELEASENAME-selenium-tls-secret
753746
```
754747

755748
You can get the `tls.crt` and `tls.key` from the Secret after the chart is deployed. For example (replace `$RELEASENAME` and `$NAMESPACE` with your values):
@@ -767,12 +760,38 @@ helm upgrade -i $RELEASENAME -n $NAMESPACE docker-selenium/selenium-grid \
767760
--set ingress.hostname="selenium-grid.prod.domain.com" \
768761
--set tls.ingress.enabled=true \
769762
--set tls.nameOverride=my-external-tls-secret \
770-
--set ingress-nginx.enabled=true \
771-
--set ingress-nginx.controller.extraArgs.default-ssl-certificate=$NAMESPACE/my-external-tls-secret
763+
--set ingress-nginx.enabled=true
772764
```
773765

774766
Grid UI can be accessed via HTTPS address `https://selenium-grid.prod.domain.com`.
775767

768+
Inline config TLS for the Ingress resource is also considered as enable secure connection to the Ingress proxy.
769+
For example, below is the config with using external TLS Secret for the Ingress resource and enable sub-chart NGINX Ingress Controller:
770+
771+
```yaml
772+
ingress:
773+
hostname: selenium-grid.prod.domain.com
774+
tls:
775+
- secretName: my-external-tls-secret
776+
hosts:
777+
- selenium-grid.prod.domain.com
778+
779+
ingress-ngnix:
780+
enabled: true
781+
```
782+
783+
In case the Ingress resource is configured without `hostname` and `tls`, the incoming traffic access via `global.K8S_PUBLIC_IP`. When sub-chart `ingress-nginx` is enabled (deploy Ingress NGINX Controller together), the default TLS secret can also be assigned via `ingress-nginx.controller.extraArgs.default-ssl-certificate`.
784+
For example (replace `$RELEASENAME` and `$NAMESPACE` with your values):
785+
786+
```bash
787+
helm upgrade -i $RELEASENAME -n $NAMESPACE docker-selenium/selenium-grid \
788+
--set global.K8S_PUBLIC_IP=$(hostname -i) \
789+
--set tls.ingress.enabled=true \
790+
--set tls.nameOverride=my-external-tls-secret \
791+
--set ingress-nginx.enabled=true \
792+
--set ingress-nginx.controller.extraArgs.default-ssl-certificate=$NAMESPACE/my-external-tls-secret
793+
```
794+
776795
### Node Registration
777796

778797
To enable secure in the node registration to make sure that the node is one you control and not a rouge node, you can enable and provide a registration secret string to Distributor, Router and

Diff for: charts/selenium-grid/templates/_helpers.tpl

+14-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Server secure connection
99
Ingress proxy forward secure connection
1010
*/}}
1111
{{- define "seleniumGrid.ingress.secureConnection" -}}
12-
{{- or $.Values.tls.enabled $.Values.tls.ingress.enabled $.Values.tls.ingress.generateTLS | ternary "true" "" -}}
12+
{{- or $.Values.tls.enabled $.Values.tls.ingress.enabled $.Values.tls.ingress.generateTLS (not (empty $.Values.ingress.tls)) | ternary "true" "" -}}
1313
{{- end -}}
1414

1515
{{/*
@@ -122,10 +122,21 @@ nginx.ingress.kubernetes.io/proxy-buffers-number: {{ . | quote }}
122122
{{- if .websocket }}
123123
nginx.org/websocket-services: {{ include ($.Values.isolateComponents | ternary "seleniumGrid.router.fullname" "seleniumGrid.hub.fullname") $ | quote }}
124124
{{- end }}
125-
{{- end }}
126-
{{- if eq (include "seleniumGrid.server.secureConnection" $) "true" }}
125+
{{- if eq (include "seleniumGrid.server.secureConnection" $) "true" }}
126+
{{- if .sslPassthrough }}
127127
nginx.ingress.kubernetes.io/ssl-passthrough: "true"
128128
nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
129+
{{- end }}
130+
{{- end }}
131+
{{- if eq (include "seleniumGrid.ingress.secureConnection" $) "true" }}
132+
{{- if not (empty .sslSecret) }}
133+
nginx.ingress.kubernetes.io/proxy-ssl-secret: {{ tpl .sslSecret $ | quote }}
134+
{{- else if (empty $.Values.ingress.tls) }}
135+
nginx.ingress.kubernetes.io/proxy-ssl-secret: {{ tpl (printf "%s/%s" $.Release.Namespace (include "seleniumGrid.tls.fullname" $)) $ | quote }}
136+
{{- else }}
137+
nginx.ingress.kubernetes.io/proxy-ssl-secret: {{ tpl (printf "%s/%s" $.Release.Namespace (index $.Values.ingress.tls 0).secretName) $ | quote }}
138+
{{- end }}
139+
{{- end }}
129140
{{- end }}
130141
{{- end -}}
131142

Diff for: charts/selenium-grid/templates/ingress.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ spec:
3636
tls:
3737
- hosts:
3838
- {{ tpl .Values.ingress.hostname $ | quote }}
39-
secretName: {{ include "seleniumGrid.tls.fullname" . | quote }}
39+
secretName: {{ include "seleniumGrid.tls.fullname" $ | quote }}
4040
{{- else if .Values.ingress.tls }}
4141
tls:
4242
{{- range .Values.ingress.tls }}
4343
- hosts:
4444
{{- range .hosts }}
4545
- {{ tpl . $ | quote }}
4646
{{- end }}
47-
secretName: {{ tpl (default "" .secretName) $ | quote }}
47+
secretName: {{ tpl (default (include "seleniumGrid.tls.fullname" $) .secretName) $ | quote }}
4848
{{- end }}
4949
{{- end }}
5050
rules:

Diff for: charts/selenium-grid/templates/jaeger-ingress.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@ spec:
2525
{{- if and (or .Values.tls.enabled .Values.tls.ingress.generateTLS) (tpl .Values.ingress.hostname $) (not .Values.ingress.tls) }}
2626
tls:
2727
- hosts:
28-
- {{ tpl .Values.ingress.hostname $ | quote }}
29-
secretName: {{ include "seleniumGrid.tls.fullname" . | quote }}
28+
- {{ tpl .Values.ingress.hostname $ }}
29+
secretName: {{ include "seleniumGrid.tls.fullname" $ | quote }}
3030
{{- else if .Values.ingress.tls }}
3131
tls:
3232
{{- range .Values.ingress.tls }}
3333
- hosts:
3434
{{- range .hosts }}
35-
- {{ tpl . $ | quote }}
35+
- {{ tpl . $ }}
3636
{{- end }}
37-
secretName: {{ tpl (.secretName) $ | quote }}
37+
secretName: {{ tpl (default (include "seleniumGrid.tls.fullname" $) .secretName) $ | quote }}
3838
{{- end }}
3939
{{- end }}
4040
rules:

Diff for: charts/selenium-grid/values.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ ingress:
121121
proxyBuffer:
122122
size: 512M
123123
number: 4
124+
sslPassthrough: true
125+
sslSecret: ""
124126
ports:
125127
http: 80
126128
https: 443

Diff for: tests/SmokeTests/__init__.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import unittest
33
import time
44
import json
5-
from ssl import _create_unverified_context
5+
import ssl
66
import requests
77
from requests.auth import HTTPBasicAuth
88

@@ -50,6 +50,13 @@ def smoke_test_container(self, port):
5050
self.assertFalse(status_json['value']['ready'], "Container is autoscaling with min replica set to 0")
5151

5252

53+
def client_verify_cert(self, port):
54+
grid_url_status = '%s://%s:%s/status' % (SELENIUM_GRID_PROTOCOL, SELENIUM_GRID_HOST, port)
55+
cert_path = os.environ.get("REQUESTS_CA_BUNDLE")
56+
response = requests.get(grid_url_status, verify=cert_path)
57+
5358
class GridTest(SmokeTests):
5459
def test_grid_is_up(self):
5560
self.smoke_test_container('%s' % SELENIUM_GRID_PORT)
61+
if SELENIUM_GRID_PROTOCOL == "https":
62+
self.client_verify_cert('%s' % SELENIUM_GRID_PORT)

Diff for: tests/charts/make/chart_test.sh

+24-8
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ fi
213213
if [ "${SECURE_USE_EXTERNAL_CERT}" = "true" ]; then
214214
HELM_COMMAND_SET_IMAGES="${HELM_COMMAND_SET_IMAGES} \
215215
--set tls.nameOverride=${EXTERNAL_TLS_SECRET_NAME} \
216+
--set ingress.nginx.sslSecret="${SELENIUM_NAMESPACE}/${EXTERNAL_TLS_SECRET_NAME}" \
216217
"
217218
cert_dir="./tests/tests"
218219
ADD_IP_ADDRESS=hostname ./${CHART_PATH}/certs/cert.sh -d ${cert_dir}
@@ -222,14 +223,29 @@ if [ "${SECURE_USE_EXTERNAL_CERT}" = "true" ]; then
222223
CHART_CERT_PATH="./tests/tests/tls.crt"
223224
fi
224225

225-
if [ "${SECURE_USE_EXTERNAL_CERT}" = "true" ]; then
226-
HELM_COMMAND_SET_IMAGES="${HELM_COMMAND_SET_IMAGES} \
227-
--set ingress-nginx.controller.extraArgs.default-ssl-certificate=${SELENIUM_NAMESPACE}/${EXTERNAL_TLS_SECRET_NAME} \
228-
"
229-
else
230-
HELM_COMMAND_SET_IMAGES="${HELM_COMMAND_SET_IMAGES} \
231-
--set ingress-nginx.controller.extraArgs.default-ssl-certificate=${SELENIUM_NAMESPACE}/${SELENIUM_TLS_SECRET_NAME} \
232-
"
226+
if [ "${SECURE_INGRESS_ONLY_CONFIG_INLINE}" = "true" ]; then
227+
if [ "${SECURE_USE_EXTERNAL_CERT}" = "true" ]; then
228+
HELM_COMMAND_SET_IMAGES="${HELM_COMMAND_SET_IMAGES} \
229+
--set ingress.tls[0].hosts[0]=${SELENIUM_GRID_HOST} \
230+
--set ingress.tls[0].secretName=${EXTERNAL_TLS_SECRET_NAME} \
231+
"
232+
else
233+
HELM_COMMAND_SET_IMAGES="${HELM_COMMAND_SET_IMAGES} \
234+
--set ingress.tls[0].hosts[0]=${SELENIUM_TLS_SECRET_NAME} \
235+
"
236+
fi
237+
fi
238+
239+
if [ "${SELENIUM_GRID_PROTOCOL}" = "https" ] && [ "${CHART_ENABLE_INGRESS_HOSTNAME}" != "true" ]; then
240+
if [ "${SECURE_USE_EXTERNAL_CERT}" = "true" ]; then
241+
HELM_COMMAND_SET_IMAGES="${HELM_COMMAND_SET_IMAGES} \
242+
--set ingress-nginx.controller.extraArgs.default-ssl-certificate=${SELENIUM_NAMESPACE}/${EXTERNAL_TLS_SECRET_NAME} \
243+
"
244+
else
245+
HELM_COMMAND_SET_IMAGES="${HELM_COMMAND_SET_IMAGES} \
246+
--set ingress-nginx.controller.extraArgs.default-ssl-certificate=${SELENIUM_NAMESPACE}/${SELENIUM_TLS_SECRET_NAME} \
247+
"
248+
fi
233249
fi
234250

235251
if [ "${SELENIUM_GRID_AUTOSCALING}" = "true" ]; then

Diff for: tests/charts/refValues/simplex-minikube.yaml

-3
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,6 @@ videoRecorder:
8787
ingress-nginx:
8888
enabled: true
8989
controller:
90-
# Set controller default certificate use the same with Selenium Grid
91-
extraArgs:
92-
default-ssl-certificate: '$(POD_NAMESPACE)/selenium-tls-secret'
9390
hostPort:
9491
enabled: true
9592
kind: DaemonSet

0 commit comments

Comments
 (0)