From f0e94196b04d2a7d0fd4d0ebd1e1c5e5cb9342cb Mon Sep 17 00:00:00 2001 From: Gustavo Michels Date: Mon, 11 May 2020 13:31:51 -0400 Subject: [PATCH] [stable/selenium] Add liveness probes and preStop hooks on browsers (#22210) * Add liveness probes and preStop hooks on browsers Signed-off-by: Gustavo Michels * Bump up chart version Signed-off-by: Gustavo Michels * Make liveness probes and preStop hooks optional and disabled by default Signed-off-by: Gustavo Michels * Update README to include new options Signed-off-by: Gustavo Michels --- stable/selenium/Chart.yaml | 2 +- stable/selenium/README.md | 8 +++++++ .../selenium/templates/chrome-daemonset.yaml | 18 ++++++++++++++ .../selenium/templates/chrome-deployment.yaml | 18 ++++++++++++++ .../templates/chromeDebug-daemonset.yaml | 18 ++++++++++++++ .../templates/chromeDebug-deployment.yaml | 18 ++++++++++++++ .../selenium/templates/firefox-daemonset.yaml | 18 ++++++++++++++ .../templates/firefox-deployment.yaml | 18 ++++++++++++++ .../templates/firefoxDebug-daemonset.yaml | 18 ++++++++++++++ .../templates/firefoxDebug-deployment.yaml | 18 ++++++++++++++ stable/selenium/values.yaml | 24 +++++++++++++++++++ 11 files changed, 177 insertions(+), 1 deletion(-) diff --git a/stable/selenium/Chart.yaml b/stable/selenium/Chart.yaml index ed591a5077..80ea08e4df 100644 --- a/stable/selenium/Chart.yaml +++ b/stable/selenium/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v1 name: selenium -version: 1.1.0 +version: 1.1.1 appVersion: 3.141.59 description: Chart for selenium grid keywords: diff --git a/stable/selenium/README.md b/stable/selenium/README.md index 800088b6ac..e6bdb6c5bf 100644 --- a/stable/selenium/README.md +++ b/stable/selenium/README.md @@ -91,6 +91,8 @@ The following table lists the configurable parameters of the Selenium chart and | `chrome.imagePullSecrets` | The secret to use for pulling the image. Will override the global parameter if set | `nil` | | `chrome.pullPolicy` | The pull policy for the node chrome image | `IfNotPresent` | | `chrome.replicas` | The number of selenium node chrome pods. This is ignored if runAsDaemonSet is enabled. | `1` | +| `chrome.enableLivenessProbe` | When true will add a liveness check to the pod | `false` | +| `chrome.waitForRunningSessions` | When true will wait for current running sessions to finish before terminating the pod | `false` | | `chrome.podAnnotations` | Annotations on the chrome pods | `{}` | | `chrome.securityContext` | SecurityContext on the chrome pods | `{"runAsUser": 1000, "fsGroup": 1000}` | | `chrome.extraEnvs` | Any additional environment variables to set in the pods | `[]` | @@ -119,6 +121,8 @@ The following table lists the configurable parameters of the Selenium chart and | `chromeDebug.imagePullSecrets` | The secret to use for pulling the image. Will override the global parameter if set | `nil` | | `chromeDebug.pullPolicy` | The selenium node chrome debug pull policy | `IfNotPresent` | | `chromeDebug.replicas` | The number of selenium node chrome debug pods. This is ignored if runAsDaemonSet is enabled. | `1` | +| `chromeDebug.enableLivenessProbe` | When true will add a liveness check to the pod | `false` | +| `chromeDebug.waitForRunningSessions` | When true will wait for current running sessions to finish before terminating the pod | `false` | | `chromeDebug.podAnnotations` | Annotations on the Chrome debug pod | `{}` | | `chromeDebug.securityContext` | SecurityContext on the Chrome debug pods | `{"runAsUser": 1000, "fsGroup": 1000}` | | `chromeDebug.extraEnvs` | Any additional environment variables to set in the pods | `[]` | @@ -147,6 +151,8 @@ The following table lists the configurable parameters of the Selenium chart and | `firefox.imagePullSecrets` | The secret to use for pulling the image. Will override the global parameter if set | `nil` | | `firefox.pullPolicy` | The selenium node firefox pull policy | `IfNotPresent` | | `firefox.replicas` | The number of selenium node firefox pods. This is ignored if runAsDaemonSet is enabled. | `1` | +| `firefox.enableLivenessProbe` | When true will add a liveness check to the pod | `false` | +| `firefox.waitForRunningSessions` | When true will wait for current running sessions to finish before terminating the pod | `false` | | `firefox.podAnnotations` | Annotations on the firefox pods | `{}` | | `firefox.securityContext` | SecurityContext on the firefox pods | `{"runAsUser": 1000, "fsGroup": 1000}` | | `firefox.extraEnvs` | Any additional environment variables to set in the pods | `[]` | @@ -173,6 +179,8 @@ The following table lists the configurable parameters of the Selenium chart and | `firefoxDebug.imagePullSecrets` | The secret to use for pulling the image. Will override the global parameter if set | `nil` | | `firefoxDebug.pullPolicy` | The selenium node firefox debug pull policy | `IfNotPresent` | | `firefoxDebug.replicas` | The number of selenium node firefox debug pods. This is ignored if runAsDaemonSet is enabled. | `1` | +| `firefoxDebug.enableLivenessProbe` | When true will add a liveness check to the pod | `false` | +| `firefoxDebug.waitForRunningSessions` | When true will wait for current running sessions to finish before terminating the pod | `false` | | `firefoxDebug.podAnnotations` | Annotations on the firefox debug pods | `{}` | | `firefoxDebug.securityContext` | SecurityContext on the firefox debug pods | `{"runAsUser": 1000, "fsGroup": 1000}` | | `firefoxDebug.extraEnvs` | Any additional environment variables to set in the pods | `[]` | diff --git a/stable/selenium/templates/chrome-daemonset.yaml b/stable/selenium/templates/chrome-daemonset.yaml index 572e7fe8fa..c3a8083c18 100644 --- a/stable/selenium/templates/chrome-daemonset.yaml +++ b/stable/selenium/templates/chrome-daemonset.yaml @@ -32,6 +32,24 @@ spec: name: jmx protocol: TCP {{- end }} + {{- if .Values.chrome.enableLivenessProbe }} + livenessProbe: + httpGet: + path: /wd/hub/status + port: {{ default "5555" .Values.chrome.nodePort }} + initialDelaySeconds: 30 + periodSeconds: 30 + failureThreshold: 1 + {{- end }} + {{- if .Values.chrome.waitForRunningSessions }} + lifecycle: + preStop: + exec: + command: + - /bin/bash + - -c + - "while [ $(wget -q -O - http://localhost:{{ default "5555" .Values.chrome.nodePort }}/wd/hub/sessions | grep -c capabilities) -gt 0 ]; do sleep 1; done" + {{- end }} env: - name: HUB_PORT_4444_TCP_ADDR value: {{ template "selenium.hub.fullname" . }} diff --git a/stable/selenium/templates/chrome-deployment.yaml b/stable/selenium/templates/chrome-deployment.yaml index ef1075abbd..3dc1606661 100644 --- a/stable/selenium/templates/chrome-deployment.yaml +++ b/stable/selenium/templates/chrome-deployment.yaml @@ -37,6 +37,24 @@ spec: name: jmx protocol: TCP {{- end }} + {{- if .Values.chrome.enableLivenessProbe }} + livenessProbe: + httpGet: + path: /wd/hub/status + port: {{ default "5555" .Values.chrome.nodePort }} + initialDelaySeconds: 30 + periodSeconds: 30 + failureThreshold: 1 + {{- end }} + {{- if .Values.chrome.waitForRunningSessions }} + lifecycle: + preStop: + exec: + command: + - /bin/bash + - -c + - "while [ $(wget -q -O - http://localhost:{{ default "5555" .Values.chrome.nodePort }}/wd/hub/sessions | grep -c capabilities) -gt 0 ]; do sleep 1; done" + {{- end }} env: - name: HUB_PORT_4444_TCP_ADDR value: {{ template "selenium.hub.fullname" . }} diff --git a/stable/selenium/templates/chromeDebug-daemonset.yaml b/stable/selenium/templates/chromeDebug-daemonset.yaml index 238f214077..2caa7d4ab8 100644 --- a/stable/selenium/templates/chromeDebug-daemonset.yaml +++ b/stable/selenium/templates/chromeDebug-daemonset.yaml @@ -34,6 +34,24 @@ spec: {{- end }} - containerPort: 5900 name: vnc + {{- if .Values.chromeDebug.enableLivenessProbe }} + livenessProbe: + httpGet: + path: /wd/hub/status + port: {{ default "5555" .Values.chromeDebug.nodePort }} + initialDelaySeconds: 30 + periodSeconds: 30 + failureThreshold: 1 + {{- end }} + {{- if .Values.chromeDebug.waitForRunningSessions }} + lifecycle: + preStop: + exec: + command: + - /bin/bash + - -c + - "while [ $(wget -q -O - http://localhost:{{ default "5555" .Values.chromeDebug.nodePort }}/wd/hub/sessions | grep -c capabilities) -gt 0 ]; do sleep 1; done" + {{- end }} env: - name: HUB_PORT_4444_TCP_ADDR value: {{ template "selenium.hub.fullname" . }} diff --git a/stable/selenium/templates/chromeDebug-deployment.yaml b/stable/selenium/templates/chromeDebug-deployment.yaml index 3c461e4075..f83e64c437 100644 --- a/stable/selenium/templates/chromeDebug-deployment.yaml +++ b/stable/selenium/templates/chromeDebug-deployment.yaml @@ -39,6 +39,24 @@ spec: {{- end }} - containerPort: 5900 name: vnc + {{- if .Values.chromeDebug.enableLivenessProbe }} + livenessProbe: + httpGet: + path: /wd/hub/status + port: {{ default "5555" .Values.chromeDebug.nodePort }} + initialDelaySeconds: 30 + periodSeconds: 30 + failureThreshold: 1 + {{- end }} + {{- if .Values.chromeDebug.waitForRunningSessions }} + lifecycle: + preStop: + exec: + command: + - /bin/bash + - -c + - "while [ $(wget -q -O - http://localhost:{{ default "5555" .Values.chromeDebug.nodePort }}/wd/hub/sessions | grep -c capabilities) -gt 0 ]; do sleep 1; done" + {{- end }} env: - name: HUB_PORT_4444_TCP_ADDR value: {{ template "selenium.hub.fullname" . }} diff --git a/stable/selenium/templates/firefox-daemonset.yaml b/stable/selenium/templates/firefox-daemonset.yaml index 51e0fdc4cf..5a457e0e01 100644 --- a/stable/selenium/templates/firefox-daemonset.yaml +++ b/stable/selenium/templates/firefox-daemonset.yaml @@ -32,6 +32,24 @@ spec: name: jmx protocol: TCP {{- end }} + {{- if .Values.firefox.enableLivenessProbe }} + livenessProbe: + httpGet: + path: /wd/hub/status + port: {{ default "5555" .Values.firefox.nodePort }} + initialDelaySeconds: 30 + periodSeconds: 30 + failureThreshold: 1 + {{- end }} + {{- if .Values.firefox.waitForRunningSessions }} + lifecycle: + preStop: + exec: + command: + - /bin/bash + - -c + - "while [ $(wget -q -O - http://localhost:{{ default "5555" .Values.firefox.nodePort }}/wd/hub/sessions | grep -c capabilities) -gt 0 ]; do sleep 1; done" + {{- end }} env: - name: HUB_PORT_4444_TCP_ADDR value: {{ template "selenium.hub.fullname" . }} diff --git a/stable/selenium/templates/firefox-deployment.yaml b/stable/selenium/templates/firefox-deployment.yaml index fe2e105936..05245a40ca 100644 --- a/stable/selenium/templates/firefox-deployment.yaml +++ b/stable/selenium/templates/firefox-deployment.yaml @@ -37,6 +37,24 @@ spec: name: jmx protocol: TCP {{- end }} + {{- if .Values.firefox.enableLivenessProbe }} + livenessProbe: + httpGet: + path: /wd/hub/status + port: {{ default "5555" .Values.firefox.nodePort }} + initialDelaySeconds: 30 + periodSeconds: 30 + failureThreshold: 1 + {{- end }} + {{- if .Values.firefox.waitForRunningSessions }} + lifecycle: + preStop: + exec: + command: + - /bin/bash + - -c + - "while [ $(wget -q -O - http://localhost:{{ default "5555" .Values.firefox.nodePort }}/wd/hub/sessions | grep -c capabilities) -gt 0 ]; do sleep 1; done" + {{- end }} env: - name: HUB_PORT_4444_TCP_ADDR value: {{ template "selenium.hub.fullname" . }} diff --git a/stable/selenium/templates/firefoxDebug-daemonset.yaml b/stable/selenium/templates/firefoxDebug-daemonset.yaml index 80b9c97921..cb31f59106 100644 --- a/stable/selenium/templates/firefoxDebug-daemonset.yaml +++ b/stable/selenium/templates/firefoxDebug-daemonset.yaml @@ -35,6 +35,24 @@ spec: {{- end }} - containerPort: 5900 name: vnc + {{- if .Values.firefoxDebug.enableLivenessProbe }} + livenessProbe: + httpGet: + path: /wd/hub/status + port: {{ default "5555" .Values.firefoxDebug.nodePort }} + initialDelaySeconds: 30 + periodSeconds: 30 + failureThreshold: 1 + {{- end }} + {{- if .Values.firefoxDebug.waitForRunningSessions }} + lifecycle: + preStop: + exec: + command: + - /bin/bash + - -c + - "while [ $(wget -q -O - http://localhost:{{ default "5555" .Values.firefoxDebug.nodePort }}/wd/hub/sessions | grep -c capabilities) -gt 0 ]; do sleep 1; done" + {{- end }} env: - name: HUB_PORT_4444_TCP_ADDR value: {{ template "selenium.hub.fullname" . }} diff --git a/stable/selenium/templates/firefoxDebug-deployment.yaml b/stable/selenium/templates/firefoxDebug-deployment.yaml index 79854fb0f6..fd19fcf27c 100644 --- a/stable/selenium/templates/firefoxDebug-deployment.yaml +++ b/stable/selenium/templates/firefoxDebug-deployment.yaml @@ -39,6 +39,24 @@ spec: {{- end }} - containerPort: 5900 name: vnc + {{- if .Values.firefoxDebug.enableLivenessProbe }} + livenessProbe: + httpGet: + path: /wd/hub/status + port: {{ default "5555" .Values.firefoxDebug.nodePort }} + initialDelaySeconds: 30 + periodSeconds: 30 + failureThreshold: 1 + {{- end }} + {{- if .Values.firefoxDebug.waitForRunningSessions }} + lifecycle: + preStop: + exec: + command: + - /bin/bash + - -c + - "while [ $(wget -q -O - http://localhost:{{ default "5555" .Values.firefoxDebug.nodePort }}/wd/hub/sessions | grep -c capabilities) -gt 0 ]; do sleep 1; done" + {{- end }} env: - name: HUB_PORT_4444_TCP_ADDR value: {{ template "selenium.hub.fullname" . }} diff --git a/stable/selenium/values.yaml b/stable/selenium/values.yaml index f1921b6588..c82d64d245 100644 --- a/stable/selenium/values.yaml +++ b/stable/selenium/values.yaml @@ -173,6 +173,12 @@ chrome: ## The number of pods in the deployment. This is ignored if runAsDaemonSet is enabled. replicas: 1 + ## When true will add a liveness check to the pod + enableLivenessProbe: false + + ## When true will wait for current running sessions to finish before terminating the pod + waitForRunningSessions: false + ## Configure annotations on the chrome pods podAnnotations: {} @@ -272,6 +278,12 @@ chromeDebug: ## The number of pods in the deployment. This is ignored if runAsDaemonSet is enabled. replicas: 1 + ## When true will add a liveness check to the pod + enableLivenessProbe: false + + ## When true will wait for current running sessions to finish before terminating the pod + waitForRunningSessions: false + ## Configure annotations on the chrome debug pods podAnnotations: {} @@ -370,6 +382,12 @@ firefox: ## The number of pods in the deployment. This is ignored if runAsDaemonSet is enabled. replicas: 1 + ## When true will add a liveness check to the pod + enableLivenessProbe: false + + ## When true will wait for current running sessions to finish before terminating the pod + waitForRunningSessions: false + ## Configure annotations on the firefox pods podAnnotations: {} @@ -455,6 +473,12 @@ firefoxDebug: ## The number of pods in the deployment. This is ignored if runAsDaemonSet is enabled. replicas: 1 + ## When true will add a liveness check to the pod + enableLivenessProbe: false + + ## When true will wait for current running sessions to finish before terminating the pod + waitForRunningSessions: false + ## Configure annotations on the firefox debug pods podAnnotations: {}