Skip to content

Commit

Permalink
feat: Ability to create/specify Service Account (#1919)
Browse files Browse the repository at this point in the history
* fix: Remove Duplicate Path Key

* feat: Add ability to specify service account with annotations

Inspired by #1783

I needed it in my environment so I figured might as well contribute to upstream

* docs: Reformat README.md, add documentation for serviceAccount

---------

Co-authored-by: Diego Molina <[email protected]>
  • Loading branch information
SurelyMario and diemol authored Aug 23, 2023
1 parent 868d06e commit 49831b1
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 12 deletions.
25 changes: 14 additions & 11 deletions charts/selenium-grid/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,22 @@ helm uninstall selenium-grid

For now, global configuration supported is:

| Parameter | Default | Description |
| ----------------------------------- | ---------------------------------- | ------------------------------------- |
| `global.seleniumGrid.imageTag` | `4.11.0-20230801` | Image tag for all selenium components |
| `global.seleniumGrid.nodesImageTag` | `4.11.0-20230801` | Image tag for browser's nodes |
| `global.seleniumGrid.imagePullSecret` | `""` | Pull secret to be used for all images |
| `global.seleniumGrid.imagePullSecret` | `""` | Pull secret to be used for all images |
| `global.seleniumGrid.affinity` | `{}` | Affinity assigned globally |
| Parameter | Default | Description |
|---------------------------------------|-------------------|---------------------------------------|
| `global.seleniumGrid.imageTag` | `4.11.0-20230801` | Image tag for all selenium components |
| `global.seleniumGrid.nodesImageTag` | `4.11.0-20230801` | Image tag for browser's nodes |
| `global.seleniumGrid.imagePullSecret` | `""` | Pull secret to be used for all images |
| `global.seleniumGrid.imagePullSecret` | `""` | Pull secret to be used for all images |
| `global.seleniumGrid.affinity` | `{}` | Affinity assigned globally |

This table contains the configuration parameters of the chart and their default values:

| Parameter | Default | Description |
| --------------------------------------- | ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
|---------------------------------------------|---------------------------------------------|----------------------------------------------------------------------------------------------------------------------------|
| `isolateComponents` | `false` | Deploy Router, Distributor, EventBus, SessionMap and Nodes separately |
| `serviceAccount.create` | `true` | Enable or disable creation of service account (if `false`, `serviceAccount.name` MUST be specified |
| `serviceAccount.name` | `""` | Name of the service account to be made or existing service account to use for all deployments and jobs |
| `serviceAccount.annotations` | `{}` | Custom annotations for service account |
| `busConfigMap.name` | `selenium-event-bus-config` | Name of the configmap that contains SE_EVENT_BUS_HOST, SE_EVENT_BUS_PUBLISH_PORT and SE_EVENT_BUS_SUBSCRIBE_PORT variables |
| `busConfigMap.annotations` | `{}` | Custom annotations for configmap |
| `nodeConfigMap.name` | `selenium-node-config` | Name of the configmap that contains common environment variables for browser nodes |
Expand Down Expand Up @@ -219,7 +222,7 @@ https://github.com/kedacore/charts/blob/main/keda/README.md for more details.

### Configuration for Selenium-Hub

You can configure the Selenium Hub with this values:
You can configure the Selenium Hub with these values:

| Parameter | Default | Description |
|---------------------------------|-------------------|--------------------------------------------------------------------------------------------------------------------------------------------------|
Expand All @@ -241,8 +244,8 @@ You can configure the Selenium Hub with this values:
| `hub.subPath` | `/` | Custom sub path for the hub deployment |
| `hub.extraEnvironmentVariables` | `nil` | Custom environment variables for selenium-hub |
| `hub.extraEnvFrom` | `nil` | Custom environment variables for selenium taken from `configMap` or `secret`-hub |
| `hub.extraVolumeMounts` | `[]` | Extra mounts of declared ExtraVolumes into pod |
| `hub.extraVolumes` | `[]` | Extra Volumes declarations to be used in the pod (can be any supported volume type: ConfigMap, Secret, PVC, NFS, etc.) |
| `hub.extraVolumeMounts` | `[]` | Extra mounts of declared ExtraVolumes into pod |
| `hub.extraVolumes` | `[]` | Extra Volumes declarations to be used in the pod (can be any supported volume type: ConfigMap, Secret, PVC, NFS, etc.) |
| `hub.resources` | `{}` | Resources for selenium-hub container |
| `hub.securityContext` | `See values.yaml` | Security context for selenium-hub container |
| `hub.serviceType` | `ClusterIP` | Kubernetes service type (see https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types) |
Expand Down
9 changes: 9 additions & 0 deletions charts/selenium-grid/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ Ingress fullname
{{- default "selenium-ingress" .Values.ingress.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Service Account fullname
*/}}
{{- define "seleniumGrid.serviceAccount.fullname" -}}
{{- .Values.serviceAccount.name | default "selenium-serviceaccount" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Is autoscaling using KEDA enabled
*/}}
Expand Down Expand Up @@ -110,6 +117,8 @@ template:
{{ toYaml . | nindent 6 }}
{{- end }}
spec:
serviceAccountName: {{ template "seleniumGrid.serviceAccount.fullname" . }}
serviceAccount: {{ template "seleniumGrid.serviceAccount.fullname" . }}
restartPolicy: {{ and (eq (include "seleniumGrid.useKEDA" .) "true") (eq .Values.autoscaling.scalingType "job") | ternary "Never" "Always" }}
{{- with .node.hostAliases }}
hostAliases: {{ toYaml . | nindent 6 }}
Expand Down
2 changes: 2 additions & 0 deletions charts/selenium-grid/templates/distributor-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ spec:
annotations: {{- toYaml . | nindent 8 }}
{{- end }}
spec:
serviceAccountName: {{ template "seleniumGrid.serviceAccount.fullname" . }}
serviceAccount: {{ template "seleniumGrid.serviceAccount.fullname" . }}
containers:
- name: selenium-distributor
{{- $imageTag := default .Values.global.seleniumGrid.imageTag .Values.components.distributor.imageTag }}
Expand Down
2 changes: 2 additions & 0 deletions charts/selenium-grid/templates/event-bus-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ spec:
annotations: {{- toYaml . | nindent 8 }}
{{- end }}
spec:
serviceAccountName: {{ template "seleniumGrid.serviceAccount.fullname" . }}
serviceAccount: {{ template "seleniumGrid.serviceAccount.fullname" . }}
containers:
- name: selenium-event-bus
{{- $imageTag := default .Values.global.seleniumGrid.imageTag .Values.components.eventBus.imageTag }}
Expand Down
2 changes: 2 additions & 0 deletions charts/selenium-grid/templates/hub-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ spec:
annotations: {{- toYaml . | nindent 8 }}
{{- end }}
spec:
serviceAccountName: {{ template "seleniumGrid.serviceAccount.fullname" . }}
serviceAccount: {{ template "seleniumGrid.serviceAccount.fullname" . }}
containers:
- name: selenium-hub
{{- $imageTag := default .Values.global.seleniumGrid.imageTag .Values.hub.imageTag }}
Expand Down
2 changes: 2 additions & 0 deletions charts/selenium-grid/templates/router-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ spec:
annotations: {{- toYaml . | nindent 8 }}
{{- end }}
spec:
serviceAccountName: {{ template "seleniumGrid.serviceAccount.fullname" . }}
serviceAccount: {{ template "seleniumGrid.serviceAccount.fullname" . }}
containers:
- name: selenium-router
{{- $imageTag := default .Values.global.seleniumGrid.imageTag .Values.components.router.imageTag }}
Expand Down
17 changes: 17 additions & 0 deletions charts/selenium-grid/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{- if .Values.serviceAccount.create }}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ template "seleniumGrid.serviceAccount.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/name: selenium-service-account
{{- include "seleniumGrid.commonLabels" . | nindent 4 }}
{{- with .Values.customLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
2 changes: 2 additions & 0 deletions charts/selenium-grid/templates/session-map-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ spec:
annotations: {{- toYaml . | nindent 8 }}
{{- end }}
spec:
serviceAccountName: {{ template "seleniumGrid.serviceAccount.fullname" . }}
serviceAccount: {{ template "seleniumGrid.serviceAccount.fullname" . }}
containers:
- name: selenium-session-map
{{- $imageTag := default .Values.global.seleniumGrid.imageTag .Values.components.sessionMap.imageTag }}
Expand Down
2 changes: 2 additions & 0 deletions charts/selenium-grid/templates/session-queuer-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ spec:
annotations: {{- toYaml . | nindent 8 }}
{{- end }}
spec:
serviceAccountName: {{ template "seleniumGrid.serviceAccount.fullname" . }}
serviceAccount: {{ template "seleniumGrid.serviceAccount.fullname" . }}
containers:
- name: selenium-session-queue
{{- $imageTag := default .Values.global.seleniumGrid.imageTag .Values.components.sessionQueue.imageTag }}
Expand Down
7 changes: 6 additions & 1 deletion charts/selenium-grid/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ basicAuth:
# Deploy Router, Distributor, EventBus, SessionMap and Nodes separately
isolateComponents: false

# Service Account for all components
serviceAccount:
create: true
name: ""
annotations: {}

# Configure the ingress resource to access the Grid installation.
ingress:
# Enable or disable ingress resource
Expand All @@ -33,7 +39,6 @@ ingress:
path: /
# TLS backend configuration for ingress resource
tls: []
path: /

# ConfigMap that contains SE_EVENT_BUS_HOST, SE_EVENT_BUS_PUBLISH_PORT and SE_EVENT_BUS_SUBSCRIBE_PORT variables
busConfigMap:
Expand Down

0 comments on commit 49831b1

Please sign in to comment.