diff --git a/charts/selenium-grid/CONFIGURATION.md b/charts/selenium-grid/CONFIGURATION.md index 41f2b07f5..37f9bb123 100644 --- a/charts/selenium-grid/CONFIGURATION.md +++ b/charts/selenium-grid/CONFIGURATION.md @@ -44,6 +44,8 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes | global.seleniumGrid.httpLogs | bool | `false` | Enable http logging. Tracing should be enabled to log http logs. | | global.seleniumGrid.updateStrategy.type | string | `"Recreate"` | Specify update strategy for all components, can be overridden individually | | global.seleniumGrid.updateStrategy.rollingUpdate | object | `{"maxSurge":1,"maxUnavailable":0}` | Specify for strategy RollingUpdate | +| global.seleniumGrid.affinity | object | `{}` | Specify affinity for all components, can be overridden individually | +| global.seleniumGrid.topologySpreadConstraints | list | `[]` | Specify topologySpreadConstraints for all components, can be overridden individually | | tls.nameOverride | string | `nil` | Name of external secret containing the TLS certificate and key | | tls.enabled | bool | `false` | Enable or disable TLS for the server components (and ingress proxy) | | tls.ingress.enabled | bool | `false` | Enable or disable TLS for the ingress proxy only | @@ -158,6 +160,8 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes | components.router.imagePullPolicy | string | `"IfNotPresent"` | Image pull policy (see https://kubernetes.io/docs/concepts/containers/images/#updating-images) | | components.router.imagePullSecret | string | `""` | Image pull secret (see https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/) | | components.router.disableUI | bool | `false` | Disable the Grid UI | +| components.router.affinity | object | `{}` | Specify affinity for router pods, this overwrites global.seleniumGrid.affinity parameter | +| components.router.topologySpreadConstraints | list | `[]` | Specify topologySpreadConstraints for router pods, this overwrites global.seleniumGrid.topologySpreadConstraints parameter | | components.router.annotations | object | `{}` | Custom annotations for router pods | | components.router.port | int | `4444` | Router container port | | components.router.nodePort | int | `30444` | Router expose NodePort | @@ -178,6 +182,8 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes | components.distributor.imagePullPolicy | string | `"IfNotPresent"` | Image pull policy (see https://kubernetes.io/docs/concepts/containers/images/#updating-images) | | components.distributor.imagePullSecret | string | `""` | Image pull secret (see https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/) | | components.distributor.newSessionThreadPoolSize | string | `nil` | Configure fixed-sized thread pool for the Distributor to create new sessions as it consumes new session requests from the queue | +| components.distributor.affinity | object | `{}` | Specify affinity for distributor pods, this overwrites global.seleniumGrid.affinity parameter | +| components.distributor.topologySpreadConstraints | list | `[]` | Specify topologySpreadConstraints for Distributor pods, this overwrites global.seleniumGrid.topologySpreadConstraints parameter | | components.distributor.annotations | object | `{}` | Custom annotations for Distributor pods | | components.distributor.port | int | `5553` | Distributor container port | | components.distributor.nodePort | int | `30553` | Distributor expose NodePort | @@ -196,6 +202,8 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes | components.eventBus.imageTag | string | `nil` | Event Bus image tag (this overwrites global.seleniumGrid.imageTag parameter) | | components.eventBus.imagePullPolicy | string | `"IfNotPresent"` | Image pull policy (see https://kubernetes.io/docs/concepts/containers/images/#updating-images) | | components.eventBus.imagePullSecret | string | `""` | Image pull secret (see https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/) | +| components.eventBus.affinity | object | `{}` | Specify affinity for Event Bus pods, this overwrites global.seleniumGrid.affinity parameter | +| components.eventBus.topologySpreadConstraints | list | `[]` | Specify topologySpreadConstraints for Event Bus pods, this overwrites global.seleniumGrid.topologySpreadConstraints parameter | | components.eventBus.annotations | object | `{}` | Custom annotations for Event Bus pods | | components.eventBus.port | int | `5557` | Event Bus container port | | components.eventBus.nodePort | int | `30557` | Event Bus expose NodePort | @@ -215,6 +223,8 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes | components.sessionMap.imageTag | string | `nil` | Session Map image tag (this overwrites global.seleniumGrid.imageTag parameter) | | components.sessionMap.imagePullPolicy | string | `"IfNotPresent"` | Image pull policy (see https://kubernetes.io/docs/concepts/containers/images/#updating-images) | | components.sessionMap.imagePullSecret | string | `""` | Image pull secret (see https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/) | +| components.sessionMap.affinity | object | `{}` | Specify affinity for Session Map pods, this overwrites global.seleniumGrid.affinity parameter | +| components.sessionMap.topologySpreadConstraints | list | `[]` | Specify topologySpreadConstraints for Session Map pods, this overwrites global.seleniumGrid.topologySpreadConstraints parameter | | components.sessionMap.annotations | object | `{}` | Custom annotations for Session Map pods | | components.sessionMap.port | int | `5556` | Session Map container port | | components.sessionMap.resources | object | `{}` | Resources for Session Map container | @@ -229,6 +239,8 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes | components.sessionQueue.imageTag | string | `nil` | Session Queue image tag (this overwrites global.seleniumGrid.imageTag parameter) | | components.sessionQueue.imagePullPolicy | string | `"IfNotPresent"` | Image pull policy (see https://kubernetes.io/docs/concepts/containers/images/#updating-images) | | components.sessionQueue.imagePullSecret | string | `""` | Image pull secret (see https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/) | +| components.sessionQueue.affinity | object | `{}` | Specify affinity for Session Queue pods, this overwrites global.seleniumGrid.affinity parameter | +| components.sessionQueue.topologySpreadConstraints | list | `[]` | Specify topologySpreadConstraints for Session Queue pods, this overwrites global.seleniumGrid.topologySpreadConstraints parameter | | components.sessionQueue.annotations | object | `{}` | Custom annotations for Session Queue pods | | components.sessionQueue.port | int | `5559` | Session Queue container port | | components.sessionQueue.nodePort | int | `30559` | Session Queue expose NodePort | @@ -247,6 +259,8 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes | hub.imageTag | string | `nil` | Selenium Hub image tag (this overwrites global.seleniumGrid.imageTag parameter) | | hub.imagePullPolicy | string | `"IfNotPresent"` | Image pull policy (see https://kubernetes.io/docs/concepts/containers/images/#updating-images) | | hub.imagePullSecret | string | `""` | Image pull secret (see https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/) | +| hub.affinity | object | `{}` | Specify affinity for Selenium Hub pods, this overwrites global.seleniumGrid.affinity parameter | +| hub.topologySpreadConstraints | list | `[]` | Specify topologySpreadConstraints for Hub pods, this overwrites global.seleniumGrid.topologySpreadConstraints parameter | | hub.annotations | object | `{}` | Custom annotations for Selenium Hub pods | | hub.labels | object | `{}` | Custom labels for Selenium Hub pods | | hub.disableUI | bool | `false` | Disable the Grid UI | @@ -313,6 +327,8 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes | chromeNode.ports | list | `[]` | Extra ports list to enable on the node container (e.g. SSH, VNC, NoVNC, etc.) | | chromeNode.port | int | `5555` | Node component port | | chromeNode.nodePort | string | `nil` | Node component expose NodePort | +| chromeNode.affinity | object | `{}` | Specify affinity for chrome-node pods, this overwrites global.seleniumGrid.affinity parameter | +| chromeNode.topologySpreadConstraints | list | `[]` | Specify topologySpreadConstraints for chrome-node pods, this overwrites global.seleniumGrid.topologySpreadConstraints parameter | | chromeNode.annotations | object | `{}` | Annotations for chrome-node pods | | chromeNode.labels | object | `{}` | Labels for chrome-node pods | | chromeNode.shareProcessNamespace | bool | `true` | Shared process namespace for chrome-node pods | @@ -361,6 +377,8 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes | firefoxNode.ports | list | `[]` | Extra ports list to enable on the node container (e.g. SSH, VNC, NoVNC, etc.) | | firefoxNode.port | int | `5555` | Node component port | | firefoxNode.nodePort | string | `nil` | Node component expose NodePort | +| firefoxNode.affinity | object | `{}` | Specify affinity for firefox-node pods, this overwrites global.seleniumGrid.affinity parameter | +| firefoxNode.topologySpreadConstraints | list | `[]` | Specify topologySpreadConstraints for firefox-node pods, this overwrites global.seleniumGrid.topologySpreadConstraints parameter | | firefoxNode.annotations | object | `{}` | Annotations for firefox-node pods | | firefoxNode.labels | object | `{}` | Labels for firefox-node pods | | firefoxNode.tolerations | list | `[]` | Tolerations for firefox-node pods | @@ -409,6 +427,8 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes | edgeNode.ports | list | `[]` | Extra ports list to enable on the node container (e.g. SSH, VNC, NoVNC, etc.) | | edgeNode.port | int | `5555` | Node component port | | edgeNode.nodePort | string | `nil` | Node component expose NodePort | +| edgeNode.affinity | object | `{}` | Specify affinity for edge-node pods, this overwrites global.seleniumGrid.affinity parameter | +| edgeNode.topologySpreadConstraints | list | `[]` | Specify topologySpreadConstraints for edge-node pods, this overwrites global.seleniumGrid.topologySpreadConstraints parameter | | edgeNode.annotations | object | `{}` | Annotations for edge-node pods | | edgeNode.labels | object | `{}` | Labels for edge-node pods | | edgeNode.tolerations | list | `[]` | Tolerations for edge-node pods | diff --git a/charts/selenium-grid/templates/_helpers.tpl b/charts/selenium-grid/templates/_helpers.tpl index 2e67f82e6..65e268b6e 100644 --- a/charts/selenium-grid/templates/_helpers.tpl +++ b/charts/selenium-grid/templates/_helpers.tpl @@ -546,8 +546,22 @@ template: {{- with .node.nodeSelector }} nodeSelector: {{- toYaml . | nindent 6 }} {{- end }} - {{- with .node.affinity }} - affinity: {{- toYaml . | nindent 6 }} + {{- if or $.Values.global.seleniumGrid.affinity .node.affinity }} + {{- $affinityYaml := default $.Values.global.seleniumGrid.affinity .node.affinity }} + affinity: {{- toYaml $affinityYaml | nindent 6 }} + {{- end }} + {{- if or $.Values.global.seleniumGrid.topologySpreadConstraints .node.topologySpreadConstraints }} + {{- $topologySpreadConstraints := default $.Values.global.seleniumGrid.topologySpreadConstraints .node.topologySpreadConstraints }} + {{- $appName := .name }} + topologySpreadConstraints: + {{- range $constraint := $topologySpreadConstraints }} + - {{ toYaml $constraint | nindent 8 | trim }} + {{- if not $constraint.labelSelector }} + labelSelector: + matchLabels: + app: {{ $appName }} + {{- end }} + {{- end }} {{- end }} {{- with .node.tolerations }} tolerations: diff --git a/charts/selenium-grid/templates/distributor-deployment.yaml b/charts/selenium-grid/templates/distributor-deployment.yaml index 94392a540..b1d9f35d7 100644 --- a/charts/selenium-grid/templates/distributor-deployment.yaml +++ b/charts/selenium-grid/templates/distributor-deployment.yaml @@ -173,7 +173,19 @@ spec: {{- if or .Values.global.seleniumGrid.affinity .Values.components.distributor.affinity }} {{- $affinityYaml := default .Values.global.seleniumGrid.affinity .Values.components.distributor.affinity }} affinity: {{- toYaml $affinityYaml | nindent 8 }} - {{- end }} + {{- end }} + {{- if or .Values.global.seleniumGrid.topologySpreadConstraints .Values.components.distributor.topologySpreadConstraints }} + {{- $topologySpreadConstraints := default .Values.global.seleniumGrid.topologySpreadConstraints .Values.components.distributor.topologySpreadConstraints }} + topologySpreadConstraints: + {{- range $constraint := $topologySpreadConstraints }} + - {{ toYaml $constraint | nindent 10 | trim }} + {{- if not $constraint.labelSelector }} + labelSelector: + matchLabels: + app: {{ template "seleniumGrid.distributor.fullname" $ }} + {{- end }} + {{- end }} + {{- end }} {{- with .Values.components.distributor.tolerations }} tolerations: {{ toYaml . | nindent 6 }} {{- end }} diff --git a/charts/selenium-grid/templates/event-bus-deployment.yaml b/charts/selenium-grid/templates/event-bus-deployment.yaml index 280ea7a4f..c441a32fb 100644 --- a/charts/selenium-grid/templates/event-bus-deployment.yaml +++ b/charts/selenium-grid/templates/event-bus-deployment.yaml @@ -84,7 +84,19 @@ spec: {{- if or .Values.global.seleniumGrid.affinity .Values.components.eventBus.affinity }} {{- $affinityYaml := default .Values.global.seleniumGrid.affinity .Values.components.eventBus.affinity }} affinity: {{- toYaml $affinityYaml | nindent 8 }} - {{- end }} + {{- end }} + {{- if or .Values.global.seleniumGrid.topologySpreadConstraints .Values.components.distributor.topologySpreadConstraints }} + {{- $topologySpreadConstraints := default .Values.global.seleniumGrid.topologySpreadConstraints .Values.components.distributor.topologySpreadConstraints }} + topologySpreadConstraints: + {{- range $constraint := $topologySpreadConstraints }} + - {{ toYaml $constraint | nindent 10 | trim }} + {{- if not $constraint.labelSelector }} + labelSelector: + matchLabels: + app: {{ template "seleniumGrid.eventBus.fullname" $ }} + {{- end }} + {{- end }} + {{- end }} {{- with .Values.components.eventBus.tolerations }} tolerations: {{ toYaml . | nindent 6 }} {{- end }} diff --git a/charts/selenium-grid/templates/hub-deployment.yaml b/charts/selenium-grid/templates/hub-deployment.yaml index 8e7464aaf..4d1b137ad 100644 --- a/charts/selenium-grid/templates/hub-deployment.yaml +++ b/charts/selenium-grid/templates/hub-deployment.yaml @@ -173,7 +173,19 @@ spec: {{- if or .Values.global.seleniumGrid.affinity .Values.hub.affinity }} {{- $affinityYaml := default .Values.global.seleniumGrid.affinity .Values.hub.affinity }} affinity: {{- toYaml $affinityYaml | nindent 8 }} - {{- end }} + {{- end }} + {{- if or .Values.global.seleniumGrid.topologySpreadConstraints .Values.components.distributor.topologySpreadConstraints }} + {{- $topologySpreadConstraints := default .Values.global.seleniumGrid.topologySpreadConstraints .Values.components.distributor.topologySpreadConstraints }} + topologySpreadConstraints: + {{- range $constraint := $topologySpreadConstraints }} + - {{ toYaml $constraint | nindent 10 | trim }} + {{- if not $constraint.labelSelector }} + labelSelector: + matchLabels: + app: {{ template "seleniumGrid.hub.fullname" $ }} + {{- end }} + {{- end }} + {{- end }} {{- with .Values.hub.tolerations }} tolerations: {{ toYaml . | nindent 6 }} {{- end }} diff --git a/charts/selenium-grid/templates/router-deployment.yaml b/charts/selenium-grid/templates/router-deployment.yaml index e7ad92897..a7e30913e 100644 --- a/charts/selenium-grid/templates/router-deployment.yaml +++ b/charts/selenium-grid/templates/router-deployment.yaml @@ -157,7 +157,19 @@ spec: {{- if or .Values.global.seleniumGrid.affinity .Values.components.router.affinity }} {{- $affinityYaml := default .Values.global.seleniumGrid.affinity .Values.components.router.affinity }} affinity: {{- toYaml $affinityYaml | nindent 8 }} - {{- end }} + {{- end }} + {{- if or .Values.global.seleniumGrid.topologySpreadConstraints .Values.components.distributor.topologySpreadConstraints }} + {{- $topologySpreadConstraints := default .Values.global.seleniumGrid.topologySpreadConstraints .Values.components.distributor.topologySpreadConstraints }} + topologySpreadConstraints: + {{- range $constraint := $topologySpreadConstraints }} + - {{ toYaml $constraint | nindent 10 | trim }} + {{- if not $constraint.labelSelector }} + labelSelector: + matchLabels: + app: {{ template "seleniumGrid.router.fullname" $ }} + {{- end }} + {{- end }} + {{- end }} {{- with .Values.components.router.tolerations }} tolerations: {{ toYaml . | nindent 6 }} {{- end }} diff --git a/charts/selenium-grid/templates/session-map-deployment.yaml b/charts/selenium-grid/templates/session-map-deployment.yaml index f0570bf9e..00e2b3f5d 100644 --- a/charts/selenium-grid/templates/session-map-deployment.yaml +++ b/charts/selenium-grid/templates/session-map-deployment.yaml @@ -83,7 +83,19 @@ spec: {{- if or .Values.global.seleniumGrid.affinity .Values.components.sessionMap.affinity }} {{- $affinityYaml := default .Values.global.seleniumGrid.affinity .Values.components.sessionMap.affinity }} affinity: {{- toYaml $affinityYaml | nindent 8 }} - {{- end }} + {{- end }} + {{- if or .Values.global.seleniumGrid.topologySpreadConstraints .Values.components.distributor.topologySpreadConstraints }} + {{- $topologySpreadConstraints := default .Values.global.seleniumGrid.topologySpreadConstraints .Values.components.distributor.topologySpreadConstraints }} + topologySpreadConstraints: + {{- range $constraint := $topologySpreadConstraints }} + - {{ toYaml $constraint | nindent 10 | trim }} + {{- if not $constraint.labelSelector }} + labelSelector: + matchLabels: + app: {{ template "seleniumGrid.sessionMap.fullname" $ }} + {{- end }} + {{- end }} + {{- end }} {{- with .Values.components.sessionMap.tolerations }} tolerations: {{ toYaml . | nindent 6 }} {{- end }} diff --git a/charts/selenium-grid/templates/session-queue-deployment.yaml b/charts/selenium-grid/templates/session-queue-deployment.yaml index 32af9d35f..10bd525a0 100644 --- a/charts/selenium-grid/templates/session-queue-deployment.yaml +++ b/charts/selenium-grid/templates/session-queue-deployment.yaml @@ -80,7 +80,19 @@ spec: {{- if or .Values.global.seleniumGrid.affinity .Values.components.sessionQueue.affinity }} {{- $affinityYaml := default .Values.global.seleniumGrid.affinity .Values.components.sessionQueue.affinity }} affinity: {{- toYaml $affinityYaml | nindent 8 }} - {{- end }} + {{- end }} + {{- if or .Values.global.seleniumGrid.topologySpreadConstraints .Values.components.distributor.topologySpreadConstraints }} + {{- $topologySpreadConstraints := default .Values.global.seleniumGrid.topologySpreadConstraints .Values.components.distributor.topologySpreadConstraints }} + topologySpreadConstraints: + {{- range $constraint := $topologySpreadConstraints }} + - {{ toYaml $constraint | nindent 10 | trim }} + {{- if not $constraint.labelSelector }} + labelSelector: + matchLabels: + app: {{ template "seleniumGrid.sessionQueue.fullname" $ }} + {{- end }} + {{- end }} + {{- end }} {{- with .Values.components.sessionQueue.tolerations }} tolerations: {{ toYaml . | nindent 6 }} {{- end }} diff --git a/charts/selenium-grid/values.yaml b/charts/selenium-grid/values.yaml index 9b788549d..c46500ec5 100644 --- a/charts/selenium-grid/values.yaml +++ b/charts/selenium-grid/values.yaml @@ -40,6 +40,14 @@ global: rollingUpdate: maxSurge: 1 maxUnavailable: 0 + # -- Specify affinity for all components, can be overridden individually + affinity: {} + # -- Specify topologySpreadConstraints for all components, can be overridden individually + topologySpreadConstraints: [] + # - maxSkew: 4 + # topologyKey: kubernetes.io/hostname + # whenUnsatisfiable: DoNotSchedule + # Note: If not define labelSelector, it will be added automatically based on "app" label in each component tls: # -- Name of external secret containing the TLS certificate and key @@ -359,6 +367,10 @@ components: # -- Disable the Grid UI disableUI: false + # -- Specify affinity for router pods, this overwrites global.seleniumGrid.affinity parameter + affinity: {} + # -- Specify topologySpreadConstraints for router pods, this overwrites global.seleniumGrid.topologySpreadConstraints parameter + topologySpreadConstraints: [] # -- Custom annotations for router pods annotations: {} # -- Router container port @@ -425,6 +437,10 @@ components: # -- Configure fixed-sized thread pool for the Distributor to create new sessions as it consumes new session requests from the queue newSessionThreadPoolSize: + # -- Specify affinity for distributor pods, this overwrites global.seleniumGrid.affinity parameter + affinity: {} + # -- Specify topologySpreadConstraints for Distributor pods, this overwrites global.seleniumGrid.topologySpreadConstraints parameter + topologySpreadConstraints: [] # -- Custom annotations for Distributor pods annotations: {} # -- Distributor container port @@ -487,6 +503,10 @@ components: # -- Image pull secret (see https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/) imagePullSecret: "" + # -- Specify affinity for Event Bus pods, this overwrites global.seleniumGrid.affinity parameter + affinity: {} + # -- Specify topologySpreadConstraints for Event Bus pods, this overwrites global.seleniumGrid.topologySpreadConstraints parameter + topologySpreadConstraints: [] # -- Custom annotations for Event Bus pods annotations: {} # -- Event Bus container port @@ -530,6 +550,10 @@ components: # -- Image pull secret (see https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/) imagePullSecret: "" + # -- Specify affinity for Session Map pods, this overwrites global.seleniumGrid.affinity parameter + affinity: {} + # -- Specify topologySpreadConstraints for Session Map pods, this overwrites global.seleniumGrid.topologySpreadConstraints parameter + topologySpreadConstraints: [] # -- Custom annotations for Session Map pods annotations: {} # -- Session Map container port @@ -563,6 +587,10 @@ components: # -- Image pull secret (see https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/) imagePullSecret: "" + # -- Specify affinity for Session Queue pods, this overwrites global.seleniumGrid.affinity parameter + affinity: {} + # -- Specify topologySpreadConstraints for Session Queue pods, this overwrites global.seleniumGrid.topologySpreadConstraints parameter + topologySpreadConstraints: [] # -- Custom annotations for Session Queue pods annotations: {} # -- Session Queue container port @@ -617,6 +645,10 @@ hub: # -- Image pull secret (see https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/) imagePullSecret: "" + # -- Specify affinity for Selenium Hub pods, this overwrites global.seleniumGrid.affinity parameter + affinity: {} + # -- Specify topologySpreadConstraints for Hub pods, this overwrites global.seleniumGrid.topologySpreadConstraints parameter + topologySpreadConstraints: [] # -- Custom annotations for Selenium Hub pods annotations: {} # -- Custom labels for Selenium Hub pods @@ -834,6 +866,10 @@ chromeNode: port: 5555 # -- Node component expose NodePort nodePort: + # -- Specify affinity for chrome-node pods, this overwrites global.seleniumGrid.affinity parameter + affinity: {} + # -- Specify topologySpreadConstraints for chrome-node pods, this overwrites global.seleniumGrid.topologySpreadConstraints parameter + topologySpreadConstraints: [] # -- Annotations for chrome-node pods annotations: {} # -- Labels for chrome-node pods @@ -1011,6 +1047,10 @@ firefoxNode: port: 5555 # -- Node component expose NodePort nodePort: + # -- Specify affinity for firefox-node pods, this overwrites global.seleniumGrid.affinity parameter + affinity: {} + # -- Specify topologySpreadConstraints for firefox-node pods, this overwrites global.seleniumGrid.topologySpreadConstraints parameter + topologySpreadConstraints: [] # -- Annotations for firefox-node pods annotations: {} # -- Labels for firefox-node pods @@ -1187,6 +1227,10 @@ edgeNode: port: 5555 # -- Node component expose NodePort nodePort: + # -- Specify affinity for edge-node pods, this overwrites global.seleniumGrid.affinity parameter + affinity: {} + # -- Specify topologySpreadConstraints for edge-node pods, this overwrites global.seleniumGrid.topologySpreadConstraints parameter + topologySpreadConstraints: [] # -- Annotations for edge-node pods annotations: {} # -- Labels for edge-node pods diff --git a/tests/charts/templates/render/dummy.yaml b/tests/charts/templates/render/dummy.yaml index 78256b569..28cef81fe 100644 --- a/tests/charts/templates/render/dummy.yaml +++ b/tests/charts/templates/render/dummy.yaml @@ -3,7 +3,7 @@ global: K8S_PUBLIC_IP: "10.10.10.10" seleniumGrid: logLevel: FINE - affinity: &affinity + affinity: podAffinity: requiredDuringSchedulingIgnoredDuringExecution: - labelSelector: @@ -13,6 +13,10 @@ global: values: - selenium topologyKey: "kubernetes.io/hostname" + topologySpreadConstraints: + - maxSkew: 4 + topologyKey: kubernetes.io/hostname + whenUnsatisfiable: DoNotSchedule autoscaling: enableWithExistingKEDA: true @@ -91,19 +95,16 @@ components: chromeNode: annotations: "restartOnUpdate": "true" - affinity: *affinity terminationGracePeriodSeconds: 7200 firefoxNode: annotations: "restartOnUpdate": "true" - affinity: *affinity terminationGracePeriodSeconds: 720 edgeNode: annotations: "restartOnUpdate": "true" - affinity: *affinity videoRecorder: enabled: true diff --git a/tests/charts/templates/render/dummy_solution.yaml b/tests/charts/templates/render/dummy_solution.yaml index b15119c70..d5204e531 100644 --- a/tests/charts/templates/render/dummy_solution.yaml +++ b/tests/charts/templates/render/dummy_solution.yaml @@ -13,6 +13,10 @@ global: values: - selenium topologyKey: "kubernetes.io/hostname" + topologySpreadConstraints: + - maxSkew: 4 + topologyKey: kubernetes.io/hostname + whenUnsatisfiable: DoNotSchedule selenium-grid: autoscaling: @@ -84,11 +88,11 @@ selenium-grid: terminationGracePeriodSeconds: 7200 firefoxNode: - affinity: *affinity - terminationGracePeriodSeconds: 720 + affinity: *affinity + terminationGracePeriodSeconds: 720 edgeNode: - affinity: *affinity + affinity: *affinity videoRecorder: enabled: true diff --git a/tests/charts/templates/test.py b/tests/charts/templates/test.py index 26b3e1dde..615a94573 100644 --- a/tests/charts/templates/test.py +++ b/tests/charts/templates/test.py @@ -284,6 +284,23 @@ def test_update_strategy_in_all_components(self): self.assertEqual(count_rolling, len(rolling), "No deployment resources found with strategy RollingUpdate") self.assertEqual(count_recreate, len(recreate), "No deployment resources found with strategy Recreate") + def test_topologySpreadConstraints_in_all_components(self): + resources_name = ['{0}selenium-chrome-node'.format(RELEASE_NAME), + '{0}selenium-edge-node'.format(RELEASE_NAME), + '{0}selenium-firefox-node'.format(RELEASE_NAME), + '{0}selenium-distributor'.format(RELEASE_NAME), + '{0}selenium-event-bus'.format(RELEASE_NAME), + '{0}selenium-router'.format(RELEASE_NAME), + '{0}selenium-session-map'.format(RELEASE_NAME), + '{0}selenium-session-queue'.format(RELEASE_NAME),] + count = 0 + for doc in LIST_OF_DOCUMENTS: + if doc['metadata']['name'] in resources_name and doc['kind'] == 'Deployment': + logger.info(f"Assert topologySpreadConstraints is set in resource {doc['metadata']['name']}") + self.assertTrue(doc['spec']['template']['spec']['topologySpreadConstraints'][0]['labelSelector']['matchLabels']['app'] == doc['metadata']['name']) + count += 1 + self.assertEqual(count, len(resources_name), "No deployment resources found with topologySpreadConstraints") + if __name__ == '__main__': failed = False try: