Skip to content

Commit 49831b1

Browse files
SurelyMariodiemol
andauthored
feat: Ability to create/specify Service Account (#1919)
* 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]>
1 parent 868d06e commit 49831b1

10 files changed

+58
-12
lines changed

charts/selenium-grid/README.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -73,19 +73,22 @@ helm uninstall selenium-grid
7373

7474
For now, global configuration supported is:
7575

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

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

8686
| Parameter | Default | Description |
87-
| --------------------------------------- | ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
87+
|---------------------------------------------|---------------------------------------------|----------------------------------------------------------------------------------------------------------------------------|
8888
| `isolateComponents` | `false` | Deploy Router, Distributor, EventBus, SessionMap and Nodes separately |
89+
| `serviceAccount.create` | `true` | Enable or disable creation of service account (if `false`, `serviceAccount.name` MUST be specified |
90+
| `serviceAccount.name` | `""` | Name of the service account to be made or existing service account to use for all deployments and jobs |
91+
| `serviceAccount.annotations` | `{}` | Custom annotations for service account |
8992
| `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 |
9093
| `busConfigMap.annotations` | `{}` | Custom annotations for configmap |
9194
| `nodeConfigMap.name` | `selenium-node-config` | Name of the configmap that contains common environment variables for browser nodes |
@@ -219,7 +222,7 @@ https://github.com/kedacore/charts/blob/main/keda/README.md for more details.
219222

220223
### Configuration for Selenium-Hub
221224

222-
You can configure the Selenium Hub with this values:
225+
You can configure the Selenium Hub with these values:
223226

224227
| Parameter | Default | Description |
225228
|---------------------------------|-------------------|--------------------------------------------------------------------------------------------------------------------------------------------------|
@@ -241,8 +244,8 @@ You can configure the Selenium Hub with this values:
241244
| `hub.subPath` | `/` | Custom sub path for the hub deployment |
242245
| `hub.extraEnvironmentVariables` | `nil` | Custom environment variables for selenium-hub |
243246
| `hub.extraEnvFrom` | `nil` | Custom environment variables for selenium taken from `configMap` or `secret`-hub |
244-
| `hub.extraVolumeMounts` | `[]` | Extra mounts of declared ExtraVolumes into pod |
245-
| `hub.extraVolumes` | `[]` | Extra Volumes declarations to be used in the pod (can be any supported volume type: ConfigMap, Secret, PVC, NFS, etc.) |
247+
| `hub.extraVolumeMounts` | `[]` | Extra mounts of declared ExtraVolumes into pod |
248+
| `hub.extraVolumes` | `[]` | Extra Volumes declarations to be used in the pod (can be any supported volume type: ConfigMap, Secret, PVC, NFS, etc.) |
246249
| `hub.resources` | `{}` | Resources for selenium-hub container |
247250
| `hub.securityContext` | `See values.yaml` | Security context for selenium-hub container |
248251
| `hub.serviceType` | `ClusterIP` | Kubernetes service type (see https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types) |

charts/selenium-grid/templates/_helpers.tpl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,13 @@ Ingress fullname
8080
{{- default "selenium-ingress" .Values.ingress.nameOverride | trunc 63 | trimSuffix "-" -}}
8181
{{- end -}}
8282

83+
{{/*
84+
Service Account fullname
85+
*/}}
86+
{{- define "seleniumGrid.serviceAccount.fullname" -}}
87+
{{- .Values.serviceAccount.name | default "selenium-serviceaccount" | trunc 63 | trimSuffix "-" -}}
88+
{{- end -}}
89+
8390
{{/*
8491
Is autoscaling using KEDA enabled
8592
*/}}
@@ -110,6 +117,8 @@ template:
110117
{{ toYaml . | nindent 6 }}
111118
{{- end }}
112119
spec:
120+
serviceAccountName: {{ template "seleniumGrid.serviceAccount.fullname" . }}
121+
serviceAccount: {{ template "seleniumGrid.serviceAccount.fullname" . }}
113122
restartPolicy: {{ and (eq (include "seleniumGrid.useKEDA" .) "true") (eq .Values.autoscaling.scalingType "job") | ternary "Never" "Always" }}
114123
{{- with .node.hostAliases }}
115124
hostAliases: {{ toYaml . | nindent 6 }}

charts/selenium-grid/templates/distributor-deployment.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ spec:
2424
annotations: {{- toYaml . | nindent 8 }}
2525
{{- end }}
2626
spec:
27+
serviceAccountName: {{ template "seleniumGrid.serviceAccount.fullname" . }}
28+
serviceAccount: {{ template "seleniumGrid.serviceAccount.fullname" . }}
2729
containers:
2830
- name: selenium-distributor
2931
{{- $imageTag := default .Values.global.seleniumGrid.imageTag .Values.components.distributor.imageTag }}

charts/selenium-grid/templates/event-bus-deployment.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ spec:
2424
annotations: {{- toYaml . | nindent 8 }}
2525
{{- end }}
2626
spec:
27+
serviceAccountName: {{ template "seleniumGrid.serviceAccount.fullname" . }}
28+
serviceAccount: {{ template "seleniumGrid.serviceAccount.fullname" . }}
2729
containers:
2830
- name: selenium-event-bus
2931
{{- $imageTag := default .Values.global.seleniumGrid.imageTag .Values.components.eventBus.imageTag }}

charts/selenium-grid/templates/hub-deployment.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ spec:
2727
annotations: {{- toYaml . | nindent 8 }}
2828
{{- end }}
2929
spec:
30+
serviceAccountName: {{ template "seleniumGrid.serviceAccount.fullname" . }}
31+
serviceAccount: {{ template "seleniumGrid.serviceAccount.fullname" . }}
3032
containers:
3133
- name: selenium-hub
3234
{{- $imageTag := default .Values.global.seleniumGrid.imageTag .Values.hub.imageTag }}

charts/selenium-grid/templates/router-deployment.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ spec:
2424
annotations: {{- toYaml . | nindent 8 }}
2525
{{- end }}
2626
spec:
27+
serviceAccountName: {{ template "seleniumGrid.serviceAccount.fullname" . }}
28+
serviceAccount: {{ template "seleniumGrid.serviceAccount.fullname" . }}
2729
containers:
2830
- name: selenium-router
2931
{{- $imageTag := default .Values.global.seleniumGrid.imageTag .Values.components.router.imageTag }}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{{- if .Values.serviceAccount.create }}
2+
apiVersion: v1
3+
kind: ServiceAccount
4+
metadata:
5+
name: {{ template "seleniumGrid.serviceAccount.fullname" . }}
6+
namespace: {{ .Release.Namespace }}
7+
labels:
8+
app.kubernetes.io/name: selenium-service-account
9+
{{- include "seleniumGrid.commonLabels" . | nindent 4 }}
10+
{{- with .Values.customLabels }}
11+
{{- toYaml . | nindent 4 }}
12+
{{- end }}
13+
{{- with .Values.serviceAccount.annotations }}
14+
annotations:
15+
{{- toYaml . | nindent 4 }}
16+
{{- end }}
17+
{{- end }}

charts/selenium-grid/templates/session-map-deployment.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ spec:
2424
annotations: {{- toYaml . | nindent 8 }}
2525
{{- end }}
2626
spec:
27+
serviceAccountName: {{ template "seleniumGrid.serviceAccount.fullname" . }}
28+
serviceAccount: {{ template "seleniumGrid.serviceAccount.fullname" . }}
2729
containers:
2830
- name: selenium-session-map
2931
{{- $imageTag := default .Values.global.seleniumGrid.imageTag .Values.components.sessionMap.imageTag }}

charts/selenium-grid/templates/session-queuer-deployment.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ spec:
2424
annotations: {{- toYaml . | nindent 8 }}
2525
{{- end }}
2626
spec:
27+
serviceAccountName: {{ template "seleniumGrid.serviceAccount.fullname" . }}
28+
serviceAccount: {{ template "seleniumGrid.serviceAccount.fullname" . }}
2729
containers:
2830
- name: selenium-session-queue
2931
{{- $imageTag := default .Values.global.seleniumGrid.imageTag .Values.components.sessionQueue.imageTag }}

charts/selenium-grid/values.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ basicAuth:
1919
# Deploy Router, Distributor, EventBus, SessionMap and Nodes separately
2020
isolateComponents: false
2121

22+
# Service Account for all components
23+
serviceAccount:
24+
create: true
25+
name: ""
26+
annotations: {}
27+
2228
# Configure the ingress resource to access the Grid installation.
2329
ingress:
2430
# Enable or disable ingress resource
@@ -33,7 +39,6 @@ ingress:
3339
path: /
3440
# TLS backend configuration for ingress resource
3541
tls: []
36-
path: /
3742

3843
# ConfigMap that contains SE_EVENT_BUS_HOST, SE_EVENT_BUS_PUBLISH_PORT and SE_EVENT_BUS_SUBSCRIBE_PORT variables
3944
busConfigMap:

0 commit comments

Comments
 (0)