Skip to content

Commit e2abbae

Browse files
authored
Merge pull request #117 from ContentSquare/master
Add Service Account Management
2 parents 85c21ed + 3aae379 commit e2abbae

File tree

5 files changed

+105
-0
lines changed

5 files changed

+105
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* Change ingress name from `<release name>-ingress` to <release name>-st2web-ingress, useful when using `stackstorm-ha` as a requirement for another chart. (#112) (by @erenatas)
55
* Fix st2web ingress which should have been defined as an Integer instead of a String (#111) (by @erenatas)
66
* Add an option to inject hostAliases in the st2actionrunner containers (#114)
7+
* Add support for Service Accounts (#117) (by @Vince-Chenal)
78

89
## v0.24.0
910
* Fix st2web ingress to use `/` path by default instead of `/*`, useful for nginx ingress controller (#103) (by @erenatas)

templates/_helpers.tpl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# Expand the name of the chart.
2+
{{- define "stackstorm-ha.name" -}}
3+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
4+
{{- end -}}
5+
16
# Image pull secret used to access private docker.stackstorm.com Docker registry with Enterprise images
27
{{- define "imagePullSecret" }}
38
{{- if required "Missing context '.Values.enterprise.enabled'!" .Values.enterprise.enabled -}}
@@ -23,6 +28,13 @@ stackstorm
2328
{{- end -}}
2429
{{- end -}}
2530

31+
{{/*
32+
Create the name of the stackstorm-ha service account to use
33+
*/}}
34+
{{- define "stackstorm-ha.serviceAccountName" -}}
35+
{{- default .Chart.Name .Values.serviceAccount.serviceAccountName -}}
36+
{{- end -}}
37+
2638
# Generate '-enterprise' suffix only when it's needed for resource names, docker images, etc
2739
{{- define "enterpriseSuffix" -}}
2840
{{ if required "Missing context '.Values.enterprise.enabled'!" .Values.enterprise.enabled }}-enterprise{{ end }}

templates/deployments.yaml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ spec:
8686
readOnly: true
8787
resources:
8888
{{ toYaml .Values.st2auth.resources | indent 10 }}
89+
{{- if .Values.st2auth.serviceAccount.attach }}
90+
serviceAccountName: {{ template "stackstorm-ha.serviceAccountName" . }}
91+
{{- end }}
8992
volumes:
9093
- name: st2-config-vol
9194
configMap:
@@ -211,6 +214,9 @@ spec:
211214
{{- end }}
212215
resources:
213216
{{ toYaml .Values.st2api.resources | indent 10 }}
217+
{{- if .Values.st2api.serviceAccount.attach }}
218+
serviceAccountName: {{ template "stackstorm-ha.serviceAccountName" . }}
219+
{{- end }}
214220
volumes:
215221
- name: st2-config-vol
216222
configMap:
@@ -294,6 +300,9 @@ spec:
294300
subPath: st2.user.conf
295301
resources:
296302
{{ toYaml .Values.st2stream.resources | indent 10 }}
303+
{{- if .Values.st2stream.serviceAccount.attach }}
304+
serviceAccountName: {{ template "stackstorm-ha.serviceAccountName" . }}
305+
{{- end }}
297306
volumes:
298307
- name: st2-config-vol
299308
configMap:
@@ -377,6 +386,9 @@ spec:
377386
volumeMounts: []
378387
resources:
379388
{{ toYaml .Values.st2web.resources | indent 10 }}
389+
{{- if .Values.st2web.serviceAccount.attach }}
390+
serviceAccountName: {{ template "stackstorm-ha.serviceAccountName" . }}
391+
{{- end }}
380392
volumes: []
381393
{{- with .Values.st2web.nodeSelector }}
382394
nodeSelector:
@@ -449,6 +461,9 @@ spec:
449461
subPath: st2.user.conf
450462
resources:
451463
{{ toYaml .Values.st2rulesengine.resources | indent 10 }}
464+
{{- if .Values.st2rulesengine.serviceAccount.attach }}
465+
serviceAccountName: {{ template "stackstorm-ha.serviceAccountName" . }}
466+
{{- end }}
452467
volumes:
453468
- name: st2-config-vol
454469
configMap:
@@ -525,6 +540,9 @@ spec:
525540
subPath: st2.user.conf
526541
resources:
527542
{{ toYaml .Values.st2timersengine.resources | indent 10 }}
543+
{{- if .Values.st2timersengine.serviceAccount.attach }}
544+
serviceAccountName: {{ template "stackstorm-ha.serviceAccountName" . }}
545+
{{- end }}
528546
volumes:
529547
- name: st2-config-vol
530548
configMap:
@@ -600,6 +618,9 @@ spec:
600618
subPath: st2.user.conf
601619
resources:
602620
{{ toYaml .Values.st2workflowengine.resources | indent 10 }}
621+
{{- if .Values.st2workflowengine.serviceAccount.attach }}
622+
serviceAccountName: {{ template "stackstorm-ha.serviceAccountName" . }}
623+
{{- end }}
603624
volumes:
604625
- name: st2-config-vol
605626
configMap:
@@ -674,6 +695,9 @@ spec:
674695
subPath: st2.user.conf
675696
resources:
676697
{{ toYaml .Values.st2scheduler.resources | indent 10 }}
698+
{{- if .Values.st2scheduler.serviceAccount.attach }}
699+
serviceAccountName: {{ template "stackstorm-ha.serviceAccountName" . }}
700+
{{- end }}
677701
volumes:
678702
- name: st2-config-vol
679703
configMap:
@@ -749,6 +773,9 @@ spec:
749773
subPath: st2.user.conf
750774
resources:
751775
{{ toYaml .Values.st2notifier.resources | indent 10 }}
776+
{{- if .Values.st2notifier.serviceAccount.attach }}
777+
serviceAccountName: {{ template "stackstorm-ha.serviceAccountName" . }}
778+
{{- end }}
752779
volumes:
753780
- name: st2-config-vol
754781
configMap:
@@ -886,6 +913,9 @@ spec:
886913
{{- end }}
887914
resources:
888915
{{ toYaml .resources | indent 10 }}
916+
{{- if .serviceAccount.attach }}
917+
serviceAccountName: {{ template "stackstorm-ha.serviceAccountName" $ }}
918+
{{- end }}
889919
volumes:
890920
- name: st2-config-vol
891921
configMap:
@@ -1020,6 +1050,9 @@ spec:
10201050
{{- end }}
10211051
resources:
10221052
{{ toYaml .Values.st2actionrunner.resources | indent 10 }}
1053+
{{- if .Values.st2actionrunner.serviceAccount.attach }}
1054+
serviceAccountName: {{ template "stackstorm-ha.serviceAccountName" . }}
1055+
{{- end }}
10231056
volumes:
10241057
- name: st2-config-vol
10251058
configMap:
@@ -1109,6 +1142,9 @@ spec:
11091142
subPath: st2.user.conf
11101143
resources:
11111144
{{ toYaml .Values.st2garbagecollector.resources | indent 10 }}
1145+
{{- if .Values.st2garbagecollector.serviceAccount.attach }}
1146+
serviceAccountName: {{ template "stackstorm-ha.serviceAccountName" . }}
1147+
{{- end }}
11121148
volumes:
11131149
- name: st2-config-vol
11141150
configMap:
@@ -1389,6 +1425,9 @@ spec:
13891425
periodSeconds: 30
13901426
resources:
13911427
{{ toYaml .Values.st2chatops.resources | indent 10 }}
1428+
{{- if .Values.st2chatops.serviceAccount.attach }}
1429+
serviceAccountName: {{ template "stackstorm-ha.serviceAccountName" . }}
1430+
{{- end }}
13921431
{{- with .Values.st2chatops.nodeSelector }}
13931432
nodeSelector:
13941433
{{ toYaml . | indent 8 }}

templates/service-account.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{{- if .Values.serviceAccount.create }}
2+
---
3+
apiVersion: v1
4+
kind: ServiceAccount
5+
metadata:
6+
name: {{ template "stackstorm-ha.serviceAccountName" . }}
7+
{{- if .Values.serviceAccount.serviceAccountAnnotations }}
8+
annotations:
9+
{{ toYaml .Values.serviceAccount.serviceAccountAnnotations | indent 4 }}
10+
{{- end }}
11+
labels:
12+
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
13+
app: "{{ template "stackstorm-ha.name" . }}"
14+
heritage: "{{ .Release.Service }}"
15+
release: "{{ .Release.Name }}"
16+
{{- end }}

values.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,17 @@ enterprise:
5353
# roles:
5454
# - "admin"
5555

56+
##
57+
## Service Account
58+
##
59+
serviceAccount:
60+
# Whether the Chart should create the service account or not
61+
create: true
62+
# Used to define service account annotations
63+
serviceAccountAnnotations: {}
64+
# Used to override service account name
65+
serviceAccountName:
66+
5667
##
5768
## StackStorm shared variables
5869
##
@@ -103,6 +114,8 @@ st2:
103114
affinity: {}
104115
nodeSelector: {}
105116
tolerations: []
117+
serviceAccount:
118+
attach: false
106119
# Import data into StackStorm's Key/Value datastore (https://docs.stackstorm.com/datastore.html)
107120
keyvalue:
108121
#- name: st2_version
@@ -223,6 +236,8 @@ st2web:
223236
nodeSelector: {}
224237
tolerations: []
225238
affinity: {}
239+
serviceAccount:
240+
attach: false
226241
# https://docs.stackstorm.com/reference/ha.html#st2auth
227242
# Multiple st2auth processes can be behind a load balancer in an active-active configuration.
228243
st2auth:
@@ -233,6 +248,8 @@ st2auth:
233248
nodeSelector: {}
234249
tolerations: []
235250
affinity: {}
251+
serviceAccount:
252+
attach: false
236253
# https://docs.stackstorm.com/reference/ha.html#st2api
237254
# Multiple st2api process can be behind a load balancer in an active-active configuration.
238255
st2api:
@@ -243,6 +260,8 @@ st2api:
243260
nodeSelector: {}
244261
tolerations: []
245262
affinity: {}
263+
serviceAccount:
264+
attach: false
246265
# https://docs.stackstorm.com/reference/ha.html#st2stream
247266
# Multiple st2stream process can be behind a load balancer in an active-active configuration.
248267
st2stream:
@@ -253,6 +272,8 @@ st2stream:
253272
nodeSelector: {}
254273
tolerations: []
255274
affinity: {}
275+
serviceAccount:
276+
attach: false
256277
# https://docs.stackstorm.com/reference/ha.html#st2rulesengine
257278
# Multiple st2rulesengine processes can run in active-active with only connections to MongoDB and RabbitMQ. All these will share the TriggerInstance load and naturally pick up more work if one or more of the processes becomes unavailable.
258279
st2rulesengine:
@@ -263,6 +284,8 @@ st2rulesengine:
263284
nodeSelector: {}
264285
tolerations: []
265286
affinity: {}
287+
serviceAccount:
288+
attach: false
266289
# https://docs.stackstorm.com/reference/ha.html#st2timersengine
267290
# Only single replica is created via K8s Deployment as timersengine can't work in active-active mode at the moment and it relies on K8s failover/reschedule capabilities to address cases of process failure.
268291
st2timersengine:
@@ -272,6 +295,8 @@ st2timersengine:
272295
nodeSelector: {}
273296
tolerations: []
274297
affinity: {}
298+
serviceAccount:
299+
attach: false
275300
# https://docs.stackstorm.com/reference/ha.html#st2workflowengine
276301
# Multiple st2workflowengine processes can run in active-active mode and will share the load and pick up more work if one or more of the processes become available.
277302
st2workflowengine:
@@ -282,6 +307,8 @@ st2workflowengine:
282307
nodeSelector: {}
283308
tolerations: []
284309
affinity: {}
310+
serviceAccount:
311+
attach: false
285312
# https://docs.stackstorm.com/reference/ha.html#st2scheduler
286313
# TODO: Description TBD
287314
st2scheduler:
@@ -292,6 +319,8 @@ st2scheduler:
292319
nodeSelector: {}
293320
tolerations: []
294321
affinity: {}
322+
serviceAccount:
323+
attach: false
295324
# https://docs.stackstorm.com/reference/ha.html#st2notifier
296325
# st2notifier runs in active-active mode and requires for that coordination backend like Redis or Zookeeper
297326
st2notifier:
@@ -302,6 +331,8 @@ st2notifier:
302331
nodeSelector: {}
303332
tolerations: []
304333
affinity: {}
334+
serviceAccount:
335+
attach: false
305336
# https://docs.stackstorm.com/reference/ha.html#st2actionrunner
306337
# Multiple st2actionrunner processes can run in active-active with only connections to MongoDB and RabbitMQ. Work gets naturally
307338
# distributed across runners via RabbitMQ. Adding more st2actionrunner processes increases the ability of StackStorm to execute actions.
@@ -322,6 +353,8 @@ st2actionrunner:
322353
# - hostnames:
323354
# - bar
324355
# ip: 8.8.8.8
356+
serviceAccount:
357+
attach: false
325358

326359
# https://docs.stackstorm.com/reference/ha.html#st2garbagecollector
327360
# Optional service that cleans up old executions and other operations data based on setup configurations.
@@ -335,6 +368,8 @@ st2garbagecollector:
335368
nodeSelector: {}
336369
tolerations: []
337370
affinity: {}
371+
serviceAccount:
372+
attach: false
338373

339374
##
340375
## StackStorm ChatOps (https://docs.stackstorm.com/chatops/index.html)
@@ -367,6 +402,8 @@ st2chatops:
367402
nodeSelector: {}
368403
tolerations: []
369404
affinity: {}
405+
serviceAccount:
406+
attach: false
370407

371408
##
372409
## MongoDB HA configuration (3rd party chart dependency)

0 commit comments

Comments
 (0)