Skip to content

Commit 824bf74

Browse files
authored
Merge pull request #198 from cognifloyd/st2-conf-helper
Refactor: Use helper for st2-config-vol volume/volumeMounts definitions
2 parents 1bee860 + 5afe550 commit 824bf74

File tree

4 files changed

+46
-135
lines changed

4 files changed

+46
-135
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* Add optional hubot-scripts volume to st2chatops pod. To add this, define `st2chatops.hubotScriptsVolume`. (#207) (by @cognifloyd)
1414
* Add advanced pod placment (nodeSelector, affinity, tolerations) to specs for batch Jobs pods. (#193) (by @cognifloyd)
1515
* Allow adding dnsPolicy and/or dnsConfig to all pods. (#201) (by @cognifloyd)
16+
* Move st2-config-vol volume definition and list of st2-config-vol volumeMounts to helpers to reduce duplication (#198) (by @cognifloyd)
1617

1718
## v0.60.0
1819
* Switch st2 version to `v3.5dev` as a new latest development version (#187)

templates/_helpers.tpl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,21 @@ Create the name of the stackstorm-ha service account to use
7171
{{- end -}}
7272
{{- end -}}
7373

74+
# Reduce duplication of the st2.*.conf volume details
75+
{{- define "st2-config-volume-mounts" -}}
76+
- name: st2-config-vol
77+
mountPath: /etc/st2/st2.docker.conf
78+
subPath: st2.docker.conf
79+
- name: st2-config-vol
80+
mountPath: /etc/st2/st2.user.conf
81+
subPath: st2.user.conf
82+
{{- end -}}
83+
{{- define "st2-config-volume" -}}
84+
- name: st2-config-vol
85+
configMap:
86+
name: {{ $.Release.Name }}-st2-config
87+
{{- end -}}
88+
7489
{{- define "init-containers-wait-for-db" -}}
7590
{{- if index .Values "mongodb" "enabled" }}
7691
{{- $mongodb_port := (int (index .Values "mongodb" "service" "port")) }}

templates/deployments.yaml

Lines changed: 24 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,7 @@ spec:
8181
- configMapRef:
8282
name: {{ .Release.Name }}-st2-urls
8383
volumeMounts:
84-
- name: st2-config-vol
85-
mountPath: /etc/st2/st2.docker.conf
86-
subPath: st2.docker.conf
87-
- name: st2-config-vol
88-
mountPath: /etc/st2/st2.user.conf
89-
subPath: st2.user.conf
84+
{{- include "st2-config-volume-mounts" . | nindent 8 }}
9085
- name: htpasswd-vol
9186
mountPath: /etc/st2/htpasswd
9287
subPath: htpasswd
@@ -97,9 +92,7 @@ spec:
9792
serviceAccountName: {{ template "stackstorm-ha.serviceAccountName" . }}
9893
{{- end }}
9994
volumes:
100-
- name: st2-config-vol
101-
configMap:
102-
name: {{ .Release.Name }}-st2-config
95+
{{- include "st2-config-volume" . | nindent 8 }}
10396
- name: htpasswd-vol
10497
emptyDir:
10598
medium: Memory
@@ -181,12 +174,7 @@ spec:
181174
- configMapRef:
182175
name: {{ .Release.Name }}-st2-urls
183176
volumeMounts:
184-
- name: st2-config-vol
185-
mountPath: /etc/st2/st2.docker.conf
186-
subPath: st2.docker.conf
187-
- name: st2-config-vol
188-
mountPath: /etc/st2/st2.user.conf
189-
subPath: st2.user.conf
177+
{{- include "st2-config-volume-mounts" . | nindent 8 }}
190178
{{- if .Values.st2.datastore_crypto_key }}
191179
- name: st2-encryption-key-vol
192180
mountPath: /etc/st2/keys
@@ -214,9 +202,7 @@ spec:
214202
- key: datastore_crypto_key
215203
path: datastore_key.json
216204
{{- end }}
217-
- name: st2-config-vol
218-
configMap:
219-
name: {{ .Release.Name }}-st2-config
205+
{{- include "st2-config-volume" . | nindent 8 }}
220206
{{- if .Values.st2.packs.images }}
221207
{{- include "packs-volumes" . | indent 8 }}
222208
{{- end }}
@@ -291,21 +277,14 @@ spec:
291277
- configMapRef:
292278
name: {{ .Release.Name }}-st2-urls
293279
volumeMounts:
294-
- name: st2-config-vol
295-
mountPath: /etc/st2/st2.docker.conf
296-
subPath: st2.docker.conf
297-
- name: st2-config-vol
298-
mountPath: /etc/st2/st2.user.conf
299-
subPath: st2.user.conf
280+
{{- include "st2-config-volume-mounts" . | nindent 8 }}
300281
resources:
301282
{{- toYaml .Values.st2stream.resources | nindent 10 }}
302283
{{- if .Values.st2stream.serviceAccount.attach }}
303284
serviceAccountName: {{ template "stackstorm-ha.serviceAccountName" . }}
304285
{{- end }}
305286
volumes:
306-
- name: st2-config-vol
307-
configMap:
308-
name: {{ .Release.Name }}-st2-config
287+
{{- include "st2-config-volume" . | nindent 8 }}
309288
{{- if .Values.dnsPolicy }}
310289
dnsPolicy: {{ .Values.dnsPolicy }}
311290
{{- end }}
@@ -477,21 +456,14 @@ spec:
477456
- configMapRef:
478457
name: {{ .Release.Name }}-st2-urls
479458
volumeMounts:
480-
- name: st2-config-vol
481-
mountPath: /etc/st2/st2.docker.conf
482-
subPath: st2.docker.conf
483-
- name: st2-config-vol
484-
mountPath: /etc/st2/st2.user.conf
485-
subPath: st2.user.conf
459+
{{- include "st2-config-volume-mounts" . | nindent 8 }}
486460
resources:
487461
{{- toYaml .Values.st2rulesengine.resources | nindent 10 }}
488462
{{- if .Values.st2rulesengine.serviceAccount.attach }}
489463
serviceAccountName: {{ template "stackstorm-ha.serviceAccountName" . }}
490464
{{- end }}
491465
volumes:
492-
- name: st2-config-vol
493-
configMap:
494-
name: {{ .Release.Name }}-st2-config
466+
{{- include "st2-config-volume" . | nindent 8 }}
495467
{{- if .Values.st2.datastore_crypto_key }}
496468
- name: st2-encryption-key-vol
497469
secret:
@@ -570,21 +542,14 @@ spec:
570542
- configMapRef:
571543
name: {{ .Release.Name }}-st2-urls
572544
volumeMounts:
573-
- name: st2-config-vol
574-
mountPath: /etc/st2/st2.docker.conf
575-
subPath: st2.docker.conf
576-
- name: st2-config-vol
577-
mountPath: /etc/st2/st2.user.conf
578-
subPath: st2.user.conf
545+
{{- include "st2-config-volume-mounts" . | nindent 8 }}
579546
resources:
580547
{{- toYaml .Values.st2timersengine.resources | nindent 10 }}
581548
{{- if .Values.st2timersengine.serviceAccount.attach }}
582549
serviceAccountName: {{ template "stackstorm-ha.serviceAccountName" . }}
583550
{{- end }}
584551
volumes:
585-
- name: st2-config-vol
586-
configMap:
587-
name: {{ .Release.Name }}-st2-config
552+
{{- include "st2-config-volume" . | nindent 8 }}
588553
{{- if .Values.dnsPolicy }}
589554
dnsPolicy: {{ .Values.dnsPolicy }}
590555
{{- end }}
@@ -655,12 +620,7 @@ spec:
655620
- configMapRef:
656621
name: {{ .Release.Name }}-st2-urls
657622
volumeMounts:
658-
- name: st2-config-vol
659-
mountPath: /etc/st2/st2.docker.conf
660-
subPath: st2.docker.conf
661-
- name: st2-config-vol
662-
mountPath: /etc/st2/st2.user.conf
663-
subPath: st2.user.conf
623+
{{- include "st2-config-volume-mounts" . | nindent 8 }}
664624
{{- if .Values.st2.datastore_crypto_key }}
665625
- name: st2-encryption-key-vol
666626
mountPath: /etc/st2/keys
@@ -672,9 +632,7 @@ spec:
672632
serviceAccountName: {{ template "stackstorm-ha.serviceAccountName" . }}
673633
{{- end }}
674634
volumes:
675-
- name: st2-config-vol
676-
configMap:
677-
name: {{ .Release.Name }}-st2-config
635+
{{- include "st2-config-volume" . | nindent 8 }}
678636
{{- if .Values.st2.datastore_crypto_key }}
679637
- name: st2-encryption-key-vol
680638
secret:
@@ -752,12 +710,7 @@ spec:
752710
- configMapRef:
753711
name: {{ .Release.Name }}-st2-urls
754712
volumeMounts:
755-
- name: st2-config-vol
756-
mountPath: /etc/st2/st2.docker.conf
757-
subPath: st2.docker.conf
758-
- name: st2-config-vol
759-
mountPath: /etc/st2/st2.user.conf
760-
subPath: st2.user.conf
713+
{{- include "st2-config-volume-mounts" . | nindent 8 }}
761714
{{- if .Values.st2.datastore_crypto_key }}
762715
- name: st2-encryption-key-vol
763716
mountPath: /etc/st2/keys
@@ -777,9 +730,7 @@ spec:
777730
- key: datastore_crypto_key
778731
path: datastore_key.json
779732
{{- end }}
780-
- name: st2-config-vol
781-
configMap:
782-
name: {{ .Release.Name }}-st2-config
733+
{{- include "st2-config-volume" . | nindent 8 }}
783734
{{- if .Values.dnsPolicy }}
784735
dnsPolicy: {{ .Values.dnsPolicy }}
785736
{{- end }}
@@ -849,21 +800,14 @@ spec:
849800
- configMapRef:
850801
name: {{ .Release.Name }}-st2-urls
851802
volumeMounts:
852-
- name: st2-config-vol
853-
mountPath: /etc/st2/st2.docker.conf
854-
subPath: st2.docker.conf
855-
- name: st2-config-vol
856-
mountPath: /etc/st2/st2.user.conf
857-
subPath: st2.user.conf
803+
{{- include "st2-config-volume-mounts" . | nindent 8 }}
858804
resources:
859805
{{- toYaml .Values.st2notifier.resources | nindent 10 }}
860806
{{- if .Values.st2notifier.serviceAccount.attach }}
861807
serviceAccountName: {{ template "stackstorm-ha.serviceAccountName" . }}
862808
{{- end }}
863809
volumes:
864-
- name: st2-config-vol
865-
configMap:
866-
name: {{ .Release.Name }}-st2-config
810+
{{- include "st2-config-volume" . | nindent 8 }}
867811
{{- if .Values.dnsPolicy }}
868812
dnsPolicy: {{ .Values.dnsPolicy }}
869813
{{- end }}
@@ -959,12 +903,7 @@ spec:
959903
- configMapRef:
960904
name: {{ $.Release.Name }}-st2-urls
961905
volumeMounts:
962-
- name: st2-config-vol
963-
mountPath: /etc/st2/st2.docker.conf
964-
subPath: st2.docker.conf
965-
- name: st2-config-vol
966-
mountPath: /etc/st2/st2.user.conf
967-
subPath: st2.user.conf
906+
{{- include "st2-config-volume-mounts" $ | nindent 8 }}
968907
{{- if $.Values.st2.packs.images }}
969908
- name: st2-packs-vol
970909
mountPath: /opt/stackstorm/packs
@@ -992,9 +931,7 @@ spec:
992931
- key: datastore_crypto_key
993932
path: datastore_key.json
994933
{{- end }}
995-
- name: st2-config-vol
996-
configMap:
997-
name: {{ $.Release.Name }}-st2-config
934+
{{- include "st2-config-volume" $ | nindent 8 }}
998935
{{- if $.Values.st2.packs.images }}
999936
{{- include "packs-volumes" $ | indent 8 }}
1000937
{{- end }}
@@ -1081,12 +1018,7 @@ spec:
10811018
- configMapRef:
10821019
name: {{ .Release.Name }}-st2-urls
10831020
volumeMounts:
1084-
- name: st2-config-vol
1085-
mountPath: /etc/st2/st2.docker.conf
1086-
subPath: st2.docker.conf
1087-
- name: st2-config-vol
1088-
mountPath: /etc/st2/st2.user.conf
1089-
subPath: st2.user.conf
1021+
{{- include "st2-config-volume-mounts" . | nindent 8 }}
10901022
- name: st2-ssh-key-vol
10911023
mountPath: /home/stanley/.ssh/
10921024
readOnly: true
@@ -1117,9 +1049,7 @@ spec:
11171049
- key: datastore_crypto_key
11181050
path: datastore_key.json
11191051
{{- end }}
1120-
- name: st2-config-vol
1121-
configMap:
1122-
name: {{ .Release.Name }}-st2-config
1052+
{{- include "st2-config-volume" . | nindent 8 }}
11231053
- name: st2-ssh-key-vol
11241054
secret:
11251055
secretName: {{ .Release.Name }}-st2-ssh
@@ -1200,21 +1130,14 @@ spec:
12001130
- configMapRef:
12011131
name: {{ .Release.Name }}-st2-urls
12021132
volumeMounts:
1203-
- name: st2-config-vol
1204-
mountPath: /etc/st2/st2.docker.conf
1205-
subPath: st2.docker.conf
1206-
- name: st2-config-vol
1207-
mountPath: /etc/st2/st2.user.conf
1208-
subPath: st2.user.conf
1133+
{{- include "st2-config-volume-mounts" . | nindent 8 }}
12091134
resources:
12101135
{{- toYaml .Values.st2garbagecollector.resources | nindent 10 }}
12111136
{{- if .Values.st2garbagecollector.serviceAccount.attach }}
12121137
serviceAccountName: {{ template "stackstorm-ha.serviceAccountName" . }}
12131138
{{- end }}
12141139
volumes:
1215-
- name: st2-config-vol
1216-
configMap:
1217-
name: {{ .Release.Name }}-st2-config
1140+
{{- include "st2-config-volume" . | nindent 8 }}
12181141
{{- if .Values.dnsPolicy }}
12191142
dnsPolicy: {{ .Values.dnsPolicy }}
12201143
{{- end }}
@@ -1322,12 +1245,7 @@ spec:
13221245
- configMapRef:
13231246
name: {{ .Release.Name }}-st2-urls
13241247
volumeMounts:
1325-
- name: st2-config-vol
1326-
mountPath: /etc/st2/st2.docker.conf
1327-
subPath: st2.docker.conf
1328-
- name: st2-config-vol
1329-
mountPath: /etc/st2/st2.user.conf
1330-
subPath: st2.user.conf
1248+
{{- include "st2-config-volume-mounts" . | nindent 8 }}
13311249
{{- if .Values.st2.rbac.enabled }}
13321250
- name: st2-rbac-roles-vol
13331251
mountPath: /opt/stackstorm/rbac/roles/
@@ -1373,9 +1291,7 @@ spec:
13731291
- key: datastore_crypto_key
13741292
path: datastore_key.json
13751293
{{- end }}
1376-
- name: st2-config-vol
1377-
configMap:
1378-
name: {{ .Release.Name }}-st2-config
1294+
{{- include "st2-config-volume" . | nindent 8 }}
13791295
{{- if .Values.st2.rbac.enabled }}
13801296
- name: st2-rbac-roles-vol
13811297
configMap:

templates/jobs.yaml

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,7 @@ spec:
4949
- --config-file=/etc/st2/st2.docker.conf
5050
- --config-file=/etc/st2/st2.user.conf
5151
volumeMounts:
52-
- name: st2-config-vol
53-
mountPath: /etc/st2/st2.docker.conf
54-
subPath: st2.docker.conf
55-
- name: st2-config-vol
56-
mountPath: /etc/st2/st2.user.conf
57-
subPath: st2.user.conf
52+
{{- include "st2-config-volume-mounts" . | nindent 8 }}
5853
- name: st2-rbac-roles-vol
5954
mountPath: /opt/stackstorm/rbac/roles/
6055
- name: st2-rbac-assignments-vol
@@ -64,9 +59,7 @@ spec:
6459
# TODO: Find out default resource limits for this specific service (#5)
6560
#resources:
6661
volumes:
67-
- name: st2-config-vol
68-
configMap:
69-
name: {{ .Release.Name }}-st2-config
62+
{{- include "st2-config-volume" . | nindent 8 }}
7063
- name: st2-rbac-roles-vol
7164
configMap:
7265
name: {{ .Release.Name }}-st2-rbac-roles
@@ -304,12 +297,7 @@ spec:
304297
- configMapRef:
305298
name: {{ .Release.Name }}-st2-urls
306299
volumeMounts:
307-
- name: st2-config-vol
308-
mountPath: /etc/st2/st2.docker.conf
309-
subPath: st2.docker.conf
310-
- name: st2-config-vol
311-
mountPath: /etc/st2/st2.user.conf
312-
subPath: st2.user.conf
300+
{{- include "st2-config-volume-mounts" . | nindent 8 }}
313301
- name: st2client-config-vol
314302
mountPath: /root/.st2/
315303
- name: st2-kv-vol
@@ -318,9 +306,7 @@ spec:
318306
# TODO: Find out default resource limits for this specific service (#5)
319307
#resources:
320308
volumes:
321-
- name: st2-config-vol
322-
configMap:
323-
name: {{ .Release.Name }}-st2-config
309+
{{- include "st2-config-volume" . | nindent 8 }}
324310
- name: st2client-config-vol
325311
emptyDir:
326312
medium: Memory
@@ -403,12 +389,7 @@ spec:
403389
- --register-all
404390
- --register-fail-on-failure
405391
volumeMounts:
406-
- name: st2-config-vol
407-
mountPath: /etc/st2/st2.docker.conf
408-
subPath: st2.docker.conf
409-
- name: st2-config-vol
410-
mountPath: /etc/st2/st2.user.conf
411-
subPath: st2.user.conf
392+
{{- include "st2-config-volume-mounts" . | nindent 8 }}
412393
- name: st2-pack-configs-vol
413394
mountPath: /opt/stackstorm/configs/
414395
{{- if .Values.st2.packs.images }}
@@ -420,9 +401,7 @@ spec:
420401
# TODO: Find out default resource limits for this specific service (#5)
421402
#resources:
422403
volumes:
423-
- name: st2-config-vol
424-
configMap:
425-
name: {{ .Release.Name }}-st2-config
404+
{{- include "st2-config-volume" . | nindent 8 }}
426405
- name: st2-pack-configs-vol
427406
configMap:
428407
name: {{ .Release.Name }}-st2-pack-configs

0 commit comments

Comments
 (0)