Skip to content
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ KEDA_CORE_VERSION := $(or $(KEDA_CORE_VERSION),$(KEDA_CORE_VERSION),2.17.2)
KEDA_TAG_VERSION := $(or $(KEDA_TAG_VERSION),$(KEDA_TAG_VERSION),2.17.2-selenium-grid)
KEDA_BASED_NAME := $(or $(KEDA_BASED_NAME),$(KEDA_BASED_NAME),ndviet)
KEDA_BASED_TAG := $(or $(KEDA_BASED_TAG),$(KEDA_BASED_TAG),2.17.2-selenium-grid-20250721)
TEST_PATCHED_KEDA := $(or $(TEST_PATCHED_KEDA),$(TEST_PATCHED_KEDA),true)
TEST_PATCHED_KEDA := $(or $(TEST_PATCHED_KEDA),$(TEST_PATCHED_KEDA),false)

all: hub \
distributor \
Expand Down
16 changes: 10 additions & 6 deletions charts/selenium-grid/CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -412,15 +412,20 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes
| autoscaling.patchObjectFinalizers.resources | object | `{"limits":{"cpu":"200m","memory":"500Mi"},"requests":{"cpu":"100m","memory":"200Mi"}}` | Define resources for container in patch job |
| autoscaling.patchObjectFinalizers.nodeSelector | object | `{}` | Node selector for the patch job |
| autoscaling.patchObjectFinalizers.tolerations | list | `[]` | Tolerations for the patch job |
| autoscaling.scaledOptions | object | `{"maxReplicaCount":24,"minReplicaCount":0,"pollingInterval":20}` | Options for KEDA scaled resources (keep only common options used for both ScaledJob and ScaledObject) |
| autoscaling.defaultTriggerType | string | `"selenium-grid"` | Default type of trigger to use (`selenium-grid` is build-in scaler in KEDA) |
| autoscaling.defaultTriggerName | string | `"seleniumGrid"` | Default alias name of trigger type (which is used in formula if you want to add scalingModifiers to advanced spec) |
| autoscaling.scaledOptions | object | `{"maxReplicaCount":24,"minReplicaCount":0,"pollingInterval":20,"triggers":[]}` | Options for KEDA scaled resources (keep only common options used for both ScaledJob and ScaledObject) |
| autoscaling.scaledOptions.minReplicaCount | int | `0` | Minimum number of replicas |
| autoscaling.scaledOptions.maxReplicaCount | int | `24` | Maximum number of replicas |
| autoscaling.scaledOptions.pollingInterval | int | `20` | Polling interval in seconds |
| autoscaling.scaledOptions.triggers | list | `[]` | List of triggers. Be careful, the default trigger of `selenium-grid` will be overwritten if you specify this |
| autoscaling.scaledJobOptions.scalingStrategy.strategy | string | `"default"` | Scaling strategy for KEDA ScaledJob - https://keda.sh/docs/latest/reference/scaledjob-spec/#scalingstrategy |
| autoscaling.scaledJobOptions.successfulJobsHistoryLimit | int | `0` | Number of Completed jobs should be kept |
| autoscaling.scaledJobOptions.failedJobsHistoryLimit | int | `0` | Number of Failed jobs should be kept (for troubleshooting purposes) |
| autoscaling.scaledJobOptions.jobTargetRef | object | `{"backoffLimit":0,"completions":1,"parallelism":1}` | Specify job target ref for KEDA ScaledJob |
| autoscaling.scaledObjectOptions.advanced.restoreToOriginalReplicaCount | bool | `true` | |
| autoscaling.scaledObjectOptions.scaleTargetRef.kind | string | `"Deployment"` | Target reference for KEDA ScaledObject |
| autoscaling.scaledOverProvisionRatio | string | `""` | |
| autoscaling.terminationGracePeriodSeconds | int | `3600` | Define terminationGracePeriodSeconds for scalingType "deployment". Period for `deregisterLifecycle` to gracefully shut down the node before force terminating it |
| autoscaling.deregisterLifecycle | string | `nil` | Define preStop command to shut down the node gracefully when scalingType is set to "deployment" |
| crossBrowsers.chromeNode | list | `[{"nameOverride":null}]` | Additional chrome nodes, array of objects with the same structure as `chromeNode` |
Expand Down Expand Up @@ -478,12 +483,12 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes
| chromeNode.scaledOptions | string | `nil` | Override the scaled options for chrome nodes |
| chromeNode.scaledJobOptions | string | `nil` | Override the scaledJobOptions for chrome nodes |
| chromeNode.scaledObjectOptions | string | `nil` | Override the scaledObjectOptions for chrome nodes |
| chromeNode.scaledOverProvisionRatio | string | `""` | |
| chromeNode.hpa.browserName | string | `"chrome"` | browserName should match with Node stereotype and request capability is scaled by this scaler |
| chromeNode.hpa.sessionBrowserName | string | `"chrome"` | sessionBrowserName if the browserName is different from the sessionBrowserName |
| chromeNode.hpa.browserVersion | string | `""` | browserVersion should match with Node stereotype and request capability is scaled by this scaler |
| chromeNode.hpa.platformName | string | `""` | platformName should match with Node stereotype and request capability is scaled by this scaler |
| chromeNode.hpa.unsafeSsl | string | `"{{ template \"seleniumGrid.graphqlURL.unsafeSsl\" . }}"` | Skip check SSL when connecting to the Graphql endpoint |
| chromeNode.hpa.overProvisionRatio | string | `""` | The number of overprovisioning ratio to scale more than the actual number of requests. For example, over over-provisioning ratio `0.2` means 20% more than the actual requests |
| chromeNode.initContainers | list | `[]` | It is used to add initContainers in the same pod of the browser node. It should be set using the --set-json option |
| chromeNode.sidecars | list | `[]` | It is used to add sidecars proxy in the same pod of the browser node. It means it will add a new container to the deployment itself. It should be set using the --set-json option |
| chromeNode.videoRecorder | object | `{}` | Override specific video recording settings for chrome node |
Expand Down Expand Up @@ -538,12 +543,12 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes
| firefoxNode.scaledOptions | string | `nil` | Override the scaled options for firefox nodes |
| firefoxNode.scaledJobOptions | string | `nil` | Override the scaledJobOptions for firefox nodes |
| firefoxNode.scaledObjectOptions | string | `nil` | Override the scaledObjectOptions for firefox nodes |
| firefoxNode.scaledOverProvisionRatio | string | `""` | |
| firefoxNode.hpa.browserName | string | `"firefox"` | browserName should match with Node stereotype and request capability is scaled by this scaler |
| firefoxNode.hpa.sessionBrowserName | string | `"firefox"` | sessionBrowserName if the browserName is different from the sessionBrowserName |
| firefoxNode.hpa.browserVersion | string | `""` | browserVersion should match with Node stereotype and request capability is scaled by this scaler |
| firefoxNode.hpa.platformName | string | `""` | platformName should match with Node stereotype and request capability is scaled by this scaler |
| firefoxNode.hpa.unsafeSsl | string | `"{{ template \"seleniumGrid.graphqlURL.unsafeSsl\" . }}"` | Skip check SSL when connecting to the Graphql endpoint |
| firefoxNode.hpa.overProvisionRatio | string | `""` | The number of overprovisioning ratio to scale more than the actual number of requests. For example, over over-provisioning ratio `0.2` means 20% more than the actual requests |
| firefoxNode.initContainers | list | `[]` | It is used to add initContainers in the same pod of the browser node. It should be set using the --set-json option |
| firefoxNode.sidecars | list | `[]` | It is used to add sidecars proxy in the same pod of the browser node. It means it will add a new container to the deployment itself. It should be set using the --set-json option |
| firefoxNode.videoRecorder | object | `{}` | Override specific video recording settings for firefox node |
Expand Down Expand Up @@ -598,12 +603,12 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes
| edgeNode.scaledOptions | string | `nil` | Override the scaled options for edge nodes |
| edgeNode.scaledJobOptions | string | `nil` | Override the scaledJobOptions for edge nodes |
| edgeNode.scaledObjectOptions | string | `nil` | Override the scaledObjectOptions for edge nodes |
| edgeNode.scaledOverProvisionRatio | string | `""` | |
| edgeNode.hpa.browserName | string | `"MicrosoftEdge"` | browserName should match with Node stereotype and request capability is scaled by this scaler |
| edgeNode.hpa.sessionBrowserName | string | `"msedge"` | sessionBrowserName if the browserName is different from the sessionBrowserName |
| edgeNode.hpa.browserVersion | string | `""` | browserVersion should match with Node stereotype and request capability is scaled by this scaler |
| edgeNode.hpa.platformName | string | `""` | platformName should match with Node stereotype and request capability is scaled by this scaler |
| edgeNode.hpa.unsafeSsl | string | `"{{ template \"seleniumGrid.graphqlURL.unsafeSsl\" . }}"` | Skip check SSL when connecting to the Graphql endpoint |
| edgeNode.hpa.overProvisionRatio | string | `""` | The number of overprovisioning ratio to scale more than the actual number of requests. For example, over over-provisioning ratio `0.2` means 20% more than the actual requests |
| edgeNode.initContainers | list | `[]` | It is used to add initContainers in the same pod of the browser node. It should be set using the --set-json option |
| edgeNode.sidecars | list | `[]` | It is used to add sidecars proxy in the same pod of the browser node. It means it will add a new container to the deployment itself. It should be set using the --set-json option |
| edgeNode.videoRecorder | object | `{}` | Override specific video recording settings for edge node |
Expand Down Expand Up @@ -659,12 +664,12 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes
| relayNode.scaledOptions | string | `nil` | Override the scaled options for relay nodes |
| relayNode.scaledJobOptions | string | `nil` | Override the scaledJobOptions for relay nodes |
| relayNode.scaledObjectOptions | string | `nil` | Override the scaledObjectOptions for relay nodes |
| relayNode.scaledOverProvisionRatio | string | `""` | |
| relayNode.hpa.browserName | string | `""` | browserName should match with Node stereotype and request capability is scaled by this scaler |
| relayNode.hpa.sessionBrowserName | string | `""` | sessionBrowserName if the browserName is different from the sessionBrowserName |
| relayNode.hpa.browserVersion | string | `""` | browserVersion should match with Node stereotype and request capability is scaled by this scaler |
| relayNode.hpa.platformName | string | `""` | platformName should match with Node stereotype and request capability is scaled by this scaler |
| relayNode.hpa.unsafeSsl | string | `"{{ template \"seleniumGrid.graphqlURL.unsafeSsl\" . }}"` | Skip check SSL when connecting to the Graphql endpoint |
| relayNode.hpa.overProvisionRatio | string | `""` | The number of overprovisioning ratio to scale more than the actual number of requests. For example, over over-provisioning ratio `0.2` means 20% more than the actual requests |
| relayNode.initContainers | list | `[]` | It is used to add initContainers in the same pod of the browser node. It should be set using the --set-json option |
| relayNode.sidecars | list | `[]` | It is used to add sidecars proxy in the same pod of the browser node. It means it will add a new container to the deployment itself. It should be set using the --set-json option |
| relayNode.videoRecorder | object | `{}` | Override specific video recording settings for edge node |
Expand Down Expand Up @@ -737,7 +742,6 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes
| videoManager.priorityClassName | string | `""` | Priority class name for router pods |
| videoManager.extraVolumeMounts | list | `[]` | |
| videoManager.extraVolumes | list | `[]` | Extra volumes for video recorder pod |
| keda.image | object | `{"keda":{"registry":"selenium","repository":"keda","tag":"2.17.2-selenium-grid-20250721"},"metricsApiServer":{"registry":"selenium","repository":"keda-metrics-apiserver","tag":"2.17.2-selenium-grid-20250721"},"webhooks":{"registry":"selenium","repository":"keda-admission-webhooks","tag":"2.17.2-selenium-grid-20250721"}}` | Specify image for KEDA components |
| keda.additionalAnnotations | string | `nil` | Annotations for KEDA resources |
| keda.http.timeout | int | `60000` | |
| keda.webhooks | object | `{"enabled":false}` | Enable KEDA admission webhooks component |
Expand Down
49 changes: 36 additions & 13 deletions charts/selenium-grid/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -213,45 +213,68 @@ based on sum of maxReplicaCount of all enabled Nodes in autoscaling
{{- $slotSelector -}}
{{- end -}}

{{/*
Apply scaledOverProvisionRatio to scalingModifiers. Link with autoscaling template
*/}}
{{- define "seleniumGrid.autoscaling.scaledOverProvisionRatio" -}}
{{- $scalingModifier := (dict) -}}
{{- $value := default $.Values.autoscaling.scaledOverProvisionRatio .node.scaledOverProvisionRatio | float64 -}}
{{- $triggerName := $.Values.autoscaling.defaultTriggerName -}}
{{- if gt $value (1.0 | float64) -}}
{{- $scalingModifier = mergeOverwrite ($scalingModifier) (dict "advanced" (dict "scalingModifiers" (dict "formula" (printf "float(%s * %.2f)" $triggerName $value) "target" "1"))) -}}
{{- end -}}
{{- toYaml $scalingModifier -}}
{{- end -}}

{{/*
Common autoscaling spec template
*/}}
{{- define "seleniumGrid.autoscalingTemplate" -}}
{{- $spec := toYaml (dict) -}}
{{- $spec := (dict) -}}
{{- $nodeMaxSessions := default $.Values.global.seleniumGrid.nodeMaxSessions .node.nodeMaxSessions | int64 -}}
{{- $nodeEnableManagedDownloads := default $.Values.global.seleniumGrid.nodeEnableManagedDownloads .node.nodeEnableManagedDownloads -}}
{{- $nodeCustomCapabilities := default $.Values.global.seleniumGrid.nodeCustomCapabilities .node.nodeCustomCapabilities -}}
{{/* Merge with precedence from right to left */}}
{{- with $.Values.autoscaling.scaledOptions -}}
{{- $spec = mergeOverwrite ($spec | fromYaml) . | toYaml -}}
{{- $spec = mergeOverwrite ($spec) . -}}
{{- end -}}
{{- with .node.scaledOptions -}}
{{- $spec = mergeOverwrite ($spec | fromYaml) . | toYaml -}}
{{- $spec = mergeOverwrite ($spec) . -}}
{{- end -}}
{{- if eq $.Values.autoscaling.scalingType "deployment" -}}
{{- $advanced := (dict "scaleTargetRef" (dict "name" .name) "advanced" (dict "horizontalPodAutoscalerConfig" (dict "name" .name))) -}}
{{- $advanced = mergeOverwrite $advanced (include "seleniumGrid.autoscaling.scaledOverProvisionRatio" . | fromYaml) }}
{{- $spec = mergeOverwrite ($spec) $advanced -}}
{{- with $.Values.autoscaling.scaledObjectOptions -}}
{{- $spec = mergeOverwrite ($spec | fromYaml) . | toYaml -}}
{{- $spec = mergeOverwrite ($spec) . -}}
{{- end -}}
{{- with .node.scaledObjectOptions -}}
{{- $spec = mergeOverwrite ($spec | fromYaml) . | toYaml -}}
{{- $spec = mergeOverwrite ($spec) . -}}
{{- end -}}
{{- $advanced := (dict "scaleTargetRef" (dict "name" .name) "advanced" (dict "horizontalPodAutoscalerConfig" (dict "name" .name) "restoreToOriginalReplicaCount" true)) -}}
{{- $spec = mergeOverwrite ($spec | fromYaml) $advanced | toYaml -}}
{{- else if eq $.Values.autoscaling.scalingType "job" -}}
{{- $spec = mergeOverwrite ($spec) (dict "jobTargetRef" .podTemplate) -}}
{{- with $.Values.autoscaling.scaledJobOptions -}}
{{- $spec = mergeOverwrite ($spec | fromYaml) . | toYaml -}}
{{- $spec = mergeOverwrite ($spec) . -}}
{{- end -}}
{{- with .node.scaledJobOptions -}}
{{- $spec = mergeOverwrite ($spec | fromYaml) . | toYaml -}}
{{- $spec = mergeOverwrite ($spec) . -}}
{{- end -}}
{{- $spec = mergeOverwrite ($spec | fromYaml) (dict "jobTargetRef" .podTemplate) | toYaml -}}
{{- end -}}
{{- if and $spec (ne $spec "{}") -}}
{{ tpl $spec $ }}
{{- if and $spec (not (empty $spec)) -}}
{{- $cleanSpec := dict -}}
{{- range $key, $value := $spec -}}
{{- if not (empty $value) -}}
{{- $cleanSpec = set $cleanSpec $key $value -}}
{{- end -}}
{{- end -}}
{{- if not (empty $cleanSpec) -}}
{{ tpl (toYaml $cleanSpec) $ | nindent 0 }}
{{- end -}}
{{- end -}}
{{- if not $.Values.autoscaling.scaledOptions.triggers }}
triggers:
- type: selenium-grid
- type: {{ $.Values.autoscaling.defaultTriggerType }}
name: {{ $.Values.autoscaling.defaultTriggerName }}
metadata:
{{- with .node.hpa }}
{{- range $key, $value := . }}
Expand Down
Loading
Loading