Skip to content

Commit

Permalink
chart: Add templates for relay node (#2453)
Browse files Browse the repository at this point in the history
Signed-off-by: Viet Nguyen Duc <[email protected]>
  • Loading branch information
VietND96 authored Nov 1, 2024
1 parent 3042ef1 commit a862efa
Show file tree
Hide file tree
Showing 9 changed files with 388 additions and 4 deletions.
51 changes: 51 additions & 0 deletions charts/selenium-grid/CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,57 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes
| 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 |
| relayNode.enabled | bool | `false` | Enable relay nodes |
| relayNode.deploymentEnabled | bool | `true` | NOTE: Only used when autoscaling.enabled is false Enable creation of Deployment true (default) - if you want long-living pods false - for provisioning your own custom type such as Jobs |
| relayNode.updateStrategy | object | `{"type":"RollingUpdate"}` | Global update strategy will be overwritten by individual component |
| relayNode.replicas | int | `1` | Number of relay nodes |
| relayNode.imageRegistry | string | `nil` | Registry to pull the image (this overwrites global.seleniumGrid.imageRegistry parameter) |
| relayNode.imageName | string | `"node-base"` | Image of relay nodes |
| relayNode.imageTag | string | `nil` | Image of relay nodes (this overwrites global.seleniumGrid.nodesImageTag) |
| relayNode.imagePullPolicy | string | `"IfNotPresent"` | Image pull policy (see https://kubernetes.io/docs/concepts/containers/images/#updating-images) |
| relayNode.imagePullSecret | string | `""` | Image pull secret (see https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/) |
| relayNode.ports | list | `[]` | Extra ports list to enable on the node container (e.g. SSH, VNC, NoVNC, etc.) |
| relayNode.port | int | `5555` | Node component port |
| relayNode.nodePort | string | `nil` | Node component expose NodePort |
| relayNode.affinity | object | `{}` | Specify affinity for relay-node pods, this overwrites global.seleniumGrid.affinity parameter |
| relayNode.topologySpreadConstraints | list | `[]` | Specify topologySpreadConstraints for relay-node pods, this overwrites global.seleniumGrid.topologySpreadConstraints parameter |
| relayNode.annotations | object | `{}` | Annotations for relay-node pods |
| relayNode.labels | object | `{}` | Labels for relay-node pods |
| relayNode.shareProcessNamespace | bool | `true` | Shared process namespace for relay-node pods |
| relayNode.resources.requests | object | `{"cpu":"1","memory":"1Gi"}` | Request resources for relay-node pods |
| relayNode.resources.limits | object | `{"cpu":"1","memory":"2Gi"}` | Limit resources for relay-node pods |
| relayNode.securityContext | object | `{}` | SecurityContext for relay-node container |
| relayNode.tolerations | list | `[]` | Tolerations for relay-node pods |
| relayNode.nodeSelector | object | `{}` | Node selector for relay-node pods |
| relayNode.hostAliases | string | `nil` | Custom host aliases for relay nodes |
| relayNode.extraEnvironmentVariables | string | `nil` | Custom environment variables for relay nodes |
| relayNode.extraEnvFrom | string | `nil` | Custom environment variables by sourcing entire configMap, Secret, etc. for relay nodes |
| relayNode.service.enabled | bool | `false` | Create a service for node |
| relayNode.service.type | string | `"ClusterIP"` | Service type |
| relayNode.service.loadBalancerIP | string | `""` | Set specific loadBalancerIP when serviceType is LoadBalancer (see https://kubernetes.io/docs/concepts/services-networking/service/#loadbalancer) |
| relayNode.service.ports | string | `nil` | Extra ports exposed in node service |
| relayNode.service.annotations | object | `{}` | Custom annotations for service |
| relayNode.dshmVolumeSizeLimit | string | `""` | Size limit for DSH volume mounted in container (if not set, default is disabled, e.g "1Gi") |
| relayNode.priorityClassName | string | `""` | Priority class name for relay-node pods |
| relayNode.startupProbe | object | `{"enabled":true,"failureThreshold":12,"initialDelaySeconds":0,"path":"/status","periodSeconds":5,"successThreshold":1,"timeoutSeconds":60}` | Startup probe settings |
| relayNode.readinessProbe | object | `{"enabled":false,"failureThreshold":10,"initialDelaySeconds":10,"path":"/status","periodSeconds":10,"successThreshold":1,"timeoutSeconds":10}` | Readiness probe settings |
| relayNode.livenessProbe | object | `{"enabled":false,"failureThreshold":6,"initialDelaySeconds":30,"path":"/status","periodSeconds":10,"successThreshold":1,"timeoutSeconds":60}` | Liveness probe settings |
| relayNode.terminationGracePeriodSeconds | int | `30` | Time to wait for pod termination |
| relayNode.deregisterLifecycle | string | `nil` | Define preStop command to shut down the relay node gracefully. This overwrites autoscaling.deregisterLifecycle |
| relayNode.lifecycle | object | `{}` | Define postStart and preStop events. This overwrites the defined preStop in deregisterLifecycle if any |
| relayNode.extraVolumeMounts | list | `[]` | Extra volume mounts for relay-node container |
| relayNode.extraVolumes | list | `[]` | Extra volumes for relay-node pod |
| relayNode.nodeMaxSessions | string | `nil` | Override the number of max sessions per node |
| 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.hpa.browserName | string | `"chrome"` | browserName from the capability |
| relayNode.hpa.sessionBrowserName | string | `""` | sessionBrowserName if the browserName is different from the sessionBrowserName |
| relayNode.hpa.platformName | string | `"Android"` | platformName from the capability |
| relayNode.hpa.unsafeSsl | string | `"{{ template \"seleniumGrid.graphqlURL.unsafeSsl\" . }}"` | Skip check SSL when connecting to the Graphql endpoint |
| 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 |
| videoRecorder.enabled | bool | `false` | Enable video recording in all browser nodes |
| videoRecorder.name | string | `"video"` | Container name is set to resource specs |
| videoRecorder.imageRegistry | string | `nil` | Registry to pull the image (this overwrites global.seleniumGrid.imageRegistry parameter) |
Expand Down
7 changes: 7 additions & 0 deletions charts/selenium-grid/templates/_nameHelpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,13 @@ Edge node fullname
{{- tpl (default (include "seleniumGrid.component.name" (list "selenium-edge-node" $)) .Values.edgeNode.nameOverride) $ | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Relay node fullname
*/}}
{{- define "seleniumGrid.relayNode.fullname" -}}
{{- tpl (default (include "seleniumGrid.component.name" (list "selenium-relay-node" $)) .Values.relayNode.nameOverride) $ | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Ingress fullname
*/}}
Expand Down
36 changes: 36 additions & 0 deletions charts/selenium-grid/templates/relay-node-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{{- if and .Values.relayNode.enabled ((eq (include "seleniumGrid.useKEDA" .) "true") | ternary (eq .Values.autoscaling.scalingType "deployment") .Values.relayNode.deploymentEnabled) }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "seleniumGrid.relayNode.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
app: {{ template "seleniumGrid.relayNode.fullname" . }}
app.kubernetes.io/name: {{ template "seleniumGrid.relayNode.fullname" . }}
{{- include "seleniumGrid.commonLabels" . | nindent 4 }}
{{- with .Values.relayNode.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.customLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
strategy:
{{- template "seleniumGrid.updateStrategy" (list $.Values.relayNode $.Values.global.seleniumGrid) }}
{{- if not (eq (include "seleniumGrid.useKEDA" $) "true") }}
replicas: {{ .Values.relayNode.replicas }}
{{- else }}
replicas: {{ default $.Values.autoscaling.scaledOptions.minReplicaCount ($.Values.relayNode.scaledOptions).minReplicaCount }}
{{- end }}
revisionHistoryLimit: {{ .Values.global.seleniumGrid.revisionHistoryLimit }}
selector:
matchLabels:
app: {{ template "seleniumGrid.relayNode.fullname" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- $podScope := deepCopy . -}}
{{- $_ := set $podScope "name" (include "seleniumGrid.relayNode.fullname" .) -}}
{{- $_ = set $podScope "node" .Values.relayNode -}}
{{- $_ = set $podScope "recorder" (mergeOverwrite .Values.videoRecorder .Values.relayNode.videoRecorder) -}}
{{- $_ = set $podScope "uploader" (get .Values.videoRecorder (.Values.videoRecorder.uploader.name | toString)) -}}
{{- include "seleniumGrid.podTemplate" $podScope | nindent 2 }}
{{- end }}
26 changes: 26 additions & 0 deletions charts/selenium-grid/templates/relay-node-hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{{- if and .Values.relayNode.enabled (eq (include "seleniumGrid.useKEDA" .) "true") (eq .Values.autoscaling.scalingType "deployment") }}
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: {{ template "seleniumGrid.relayNode.fullname" . }}
namespace: {{ .Release.Namespace }}
annotations:
{{- with .Values.autoscaling.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
deploymentName: {{ template "seleniumGrid.relayNode.fullname" . }}
{{- include "seleniumGrid.commonLabels" . | nindent 4 }}
{{- include "seleniumGrid.autoscalingLabels" . | nindent 4 }}
{{- with .Values.relayNode.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.customLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- $podScope := deepCopy . -}}
{{- $_ := set $podScope "name" (include "seleniumGrid.relayNode.fullname" .) -}}
{{- $_ = set $podScope "node" .Values.relayNode -}}
{{- include "seleniumGrid.autoscalingTemplate" $podScope | nindent 2 }}
{{- end }}
30 changes: 30 additions & 0 deletions charts/selenium-grid/templates/relay-node-scaledjobs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{{- if and .Values.relayNode.enabled (include "seleniumGrid.useKEDA" .) (eq .Values.autoscaling.scalingType "job") }}
apiVersion: keda.sh/v1alpha1
kind: ScaledJob
metadata:
name: {{ template "seleniumGrid.relayNode.fullname" . }}
namespace: {{ .Release.Namespace }}
annotations:
{{- with .Values.autoscaling.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
app: {{ template "seleniumGrid.relayNode.fullname" . }}
app.kubernetes.io/name: {{ template "seleniumGrid.relayNode.fullname" . }}
{{- include "seleniumGrid.commonLabels" . | nindent 4 }}
{{- include "seleniumGrid.autoscalingLabels" . | nindent 4 }}
{{- with .Values.relayNode.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.customLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- $podScope := deepCopy . -}}
{{- $_ := set $podScope "name" (include "seleniumGrid.relayNode.fullname" .) -}}
{{- $_ = set $podScope "node" .Values.relayNode -}}
{{- $_ = set $podScope "recorder" (mergeOverwrite .Values.videoRecorder .Values.relayNode.videoRecorder) -}}
{{- $_ = set $podScope "uploader" (get .Values.videoRecorder (.Values.videoRecorder.uploader.name | toString)) -}}
{{- $_ = set $podScope "podTemplate" (include "seleniumGrid.podTemplate" $podScope | fromYaml) }}
{{- include "seleniumGrid.autoscalingTemplate" $podScope | nindent 2 }}
{{- end }}
43 changes: 43 additions & 0 deletions charts/selenium-grid/templates/relay-node-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{{- if and .Values.relayNode.enabled .Values.relayNode.service.enabled }}
apiVersion: v1
kind: Service
metadata:
name: {{ template "seleniumGrid.relayNode.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
name: {{ template "seleniumGrid.relayNode.fullname" . }}
{{- include "seleniumGrid.commonLabels" . | nindent 4 }}
{{- with .Values.relayNode.service.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
type: {{ .Values.relayNode.service.type }}
selector:
app: {{ template "seleniumGrid.relayNode.fullname" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- if and (eq .Values.relayNode.service.type "LoadBalancer") (.Values.relayNode.service.loadBalancerIP) }}
loadBalancerIP: {{ .Values.relayNode.service.loadBalancerIP }}
{{- end }}
ports:
- name: tcp-chrome
protocol: TCP
port: {{ .Values.relayNode.port }}
targetPort: {{ .Values.relayNode.port }}
{{- if and (eq $.Values.relayNode.service.type "NodePort") .Values.relayNode.nodePort }}
nodePort: {{ .Values.relayNode.nodePort }}
{{- end }}
{{- with .Values.relayNode.service.ports }}
{{- range . }}
- name: {{ .name }}
port: {{ .port }}
targetPort: {{ .targetPort }}
{{- if .protocol }}
protocol: {{ .protocol }}
{{- end }}
{{- if and (eq $.Values.relayNode.service.type "NodePort") .nodePort }}
nodePort: {{ .nodePort }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
Loading

0 comments on commit a862efa

Please sign in to comment.