Skip to content

Commit a795f5a

Browse files
authored
Merge pull request #333 from bmarick/jobsExtraVolumes
Enable Extra Volumes in Jobs
2 parents a2a9e1c + 11857af commit a795f5a

File tree

4 files changed

+93
-1
lines changed

4 files changed

+93
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* Add ability to create custom labels for service account.(#327)(by @SuganJoe)
1111
* Fix bug that would not set the appropriate redis connection string when using `redis.password` and `redis.usePassword` (#325) (by @rebrowning)
1212
* New Feature: Add `existingConfigSecret`. If this is defined, the `st2.secrets.conf` key within this secret will be written as /etc/st2/st2.secrets.conf and added to the end of the command line arguments of all pods. (#289) (by @eric-al/@ericreeves)
13+
* New Feature: Add `extra_volumes` to all python-based st2 jobs. (#333) (by @bmarick)
1314

1415
## v0.100.0
1516
* Switch st2 to `v3.7` as a new default stable version (#274)

templates/jobs.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ spec:
5858
mountPath: /opt/stackstorm/rbac/assignments/
5959
- name: st2-rbac-mappings-vol
6060
mountPath: /opt/stackstorm/rbac/mappings/
61+
{{- range $.Values.jobs.extra_volumes }}
62+
- name: {{ required "Each volume must have a 'name' in jobs.extra_volumes" .name }}
63+
{{- tpl (required "Each volume must have a 'mount' definition in jobs.extra_volumes" .mount | toYaml) $ | nindent 10 }}
64+
{{- end }}
6165
# TODO: Find out default resource limits for this specific service (#5)
6266
#resources:
6367
volumes:
@@ -71,6 +75,10 @@ spec:
7175
- name: st2-rbac-mappings-vol
7276
configMap:
7377
name: {{ .Release.Name }}-st2-rbac-mappings
78+
{{- range $.Values.jobs.extra_volumes }}
79+
- name: {{ required "Each volume must have a 'name' in jobs.extra_volumes" .name }}
80+
{{- tpl (required "Each volume must have a 'volume' definition in jobs.extra_volumes" .volume | toYaml) $ | nindent 10 }}
81+
{{- end }}
7482
restartPolicy: OnFailure
7583
{{- if .Values.dnsPolicy }}
7684
dnsPolicy: {{ .Values.dnsPolicy }}
@@ -192,6 +200,10 @@ spec:
192200
- name: st2-apikeys-vol
193201
mountPath: /etc/st2/apikeys.yaml
194202
subPath: apikeys.yaml
203+
{{- range $.Values.jobs.extra_volumes }}
204+
- name: {{ required "Each volume must have a 'name' in jobs.extra_volumes" .name }}
205+
{{- tpl (required "Each volume must have a 'mount' definition in jobs.extra_volumes" .mount | toYaml) $ | nindent 10 }}
206+
{{- end }}
195207
# TODO: Find out default resource limits for this specific service (#5)
196208
#resources:
197209
volumes:
@@ -201,6 +213,10 @@ spec:
201213
- name: st2-apikeys-vol
202214
secret:
203215
secretName: {{ .Release.Name }}-st2-apikeys
216+
{{- range $.Values.jobs.extra_volumes }}
217+
- name: {{ required "Each volume must have a 'name' in jobs.extra_volumes" .name }}
218+
{{- tpl (required "Each volume must have a 'volume' definition in jobs.extra_volumes" .volume | toYaml) $ | nindent 10 }}
219+
{{- end }}
204220
restartPolicy: OnFailure
205221
{{- if .Values.dnsPolicy }}
206222
dnsPolicy: {{ .Values.dnsPolicy }}
@@ -312,6 +328,10 @@ spec:
312328
- name: st2-kv-vol
313329
mountPath: /etc/st2/st2kv.yaml
314330
subPath: st2kv.yaml
331+
{{- range $.Values.jobs.extra_volumes }}
332+
- name: {{ required "Each volume must have a 'name' in jobs.extra_volumes" .name }}
333+
{{- tpl (required "Each volume must have a 'mount' definition in jobs.extra_volumes" .mount | toYaml) $ | nindent 10 }}
334+
{{- end }}
315335
# TODO: Find out default resource limits for this specific service (#5)
316336
#resources:
317337
volumes:
@@ -322,6 +342,10 @@ spec:
322342
- name: st2-kv-vol
323343
secret:
324344
secretName: {{ .Release.Name }}-st2-kv
345+
{{- range $.Values.jobs.extra_volumes }}
346+
- name: {{ required "Each volume must have a 'name' in jobs.extra_volumes" .name }}
347+
{{- tpl (required "Each volume must have a 'volume' definition in jobs.extra_volumes" .volume | toYaml) $ | nindent 10 }}
348+
{{- end }}
325349
restartPolicy: OnFailure
326350
{{- if .Values.dnsPolicy }}
327351
dnsPolicy: {{ .Values.dnsPolicy }}
@@ -424,13 +448,21 @@ spec:
424448
{{- include "stackstorm-ha.st2-config-volume-mounts" . | nindent 8 }}
425449
{{- include "stackstorm-ha.packs-volume-mounts-for-register-job" . | nindent 8 }}
426450
{{- include "stackstorm-ha.pack-configs-volume-mount" . | nindent 8 }}
451+
{{- range $.Values.jobs.extra_volumes }}
452+
- name: {{ required "Each volume must have a 'name' in jobs.extra_volumes" .name }}
453+
{{- tpl (required "Each volume must have a 'mount' definition in jobs.extra_volumes" .mount | toYaml) $ | nindent 10 }}
454+
{{- end }}
427455
# TODO: Find out default resource limits for this specific service (#5)
428456
#resources:
429457
volumes:
430458
{{- include "stackstorm-ha.overrides-configs" . | nindent 8 }}
431459
{{- include "stackstorm-ha.st2-config-volume" . | nindent 8 }}
432460
{{- include "stackstorm-ha.packs-volumes" . | nindent 8 }}
433461
{{- include "stackstorm-ha.pack-configs-volume" . | nindent 8 }}
462+
{{- range $.Values.jobs.extra_volumes }}
463+
- name: {{ required "Each volume must have a 'name' in jobs.extra_volumes" .name }}
464+
{{- tpl (required "Each volume must have a 'volume' definition in jobs.extra_volumes" .volume | toYaml) $ | nindent 10 }}
465+
{{- end }}
434466
restartPolicy: OnFailure
435467
{{- if .Values.dnsPolicy }}
436468
dnsPolicy: {{ .Values.dnsPolicy }}
@@ -548,6 +580,10 @@ spec:
548580
{{- include "stackstorm-ha.st2-config-volume-mounts" $ | nindent 8 }}
549581
{{- include "stackstorm-ha.packs-volume-mounts-for-register-job" $ | nindent 8 }}
550582
{{- include "stackstorm-ha.pack-configs-volume-mount" $ | nindent 8 }}
583+
{{- range $.Values.jobs.extra_volumes }}
584+
- name: {{ required "Each volume must have a 'name' in jobs.extra_volumes" .name }}
585+
{{- tpl (required "Each volume must have a 'mount' definition in jobs.extra_volumes" .mount | toYaml) $ | nindent 10 }}
586+
{{- end }}
551587
{{- if .resources }}
552588
resources: {{- toYaml .resources | nindent 10 }}
553589
{{- end }}
@@ -559,6 +595,10 @@ spec:
559595
{{- include "stackstorm-ha.st2-config-volume" $ | nindent 8 }}
560596
{{- include "stackstorm-ha.packs-volumes" $ | nindent 8 }}
561597
{{- include "stackstorm-ha.pack-configs-volume" $ | nindent 8 }}
598+
{{- range $.Values.jobs.extra_volumes }}
599+
- name: {{ required "Each volume must have a 'name' in jobs.extra_volumes" .name }}
600+
{{- tpl (required "Each volume must have a 'volume' definition in jobs.extra_volumes" .volume | toYaml) $ | nindent 10 }}
601+
{{- end }}
562602
restartPolicy: OnFailure
563603
{{- if $.Values.dnsPolicy }}
564604
dnsPolicy: {{ $.Values.dnsPolicy }}

tests/unit/extra_volumes_test.yaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
suite: Extra Volumes
3+
templates:
4+
- jobs.yaml
5+
6+
# included templates must also be listed
7+
- configmaps_overrides.yaml
8+
- configmaps_packs.yaml
9+
- configmaps_rbac.yaml
10+
- configmaps_st2-conf.yaml
11+
- configmaps_st2-urls.yaml
12+
- configmaps_st2web.yaml
13+
- secrets_datastore_crypto_key.yaml
14+
- secrets_ssh.yaml
15+
- secrets_st2apikeys.yaml
16+
- secrets_st2auth.yaml
17+
- secrets_st2chatops.yaml
18+
19+
tests:
20+
- it: Jobs add extra_volumes
21+
template: jobs.yaml
22+
set:
23+
jobs:
24+
extra_volumes:
25+
- name: custom-config-map-volume
26+
mount:
27+
mountPath: /config/config.yml
28+
subPath: config.yml
29+
volume:
30+
configMap:
31+
name: customConfig
32+
asserts:
33+
- hasDocuments:
34+
count: 3
35+
# job volumeMounts
36+
- contains:
37+
path: spec.template.spec.volumes
38+
content:
39+
name: custom-config-map-volume
40+
count: 1
41+
any: true
42+
- contains:
43+
path: spec.template.spec.containers[0].volumeMounts
44+
content:
45+
name: custom-config-map-volume
46+
count: 1
47+
any: true

values.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ st2:
8888

8989

9090
# Custom StackStorm config (st2.secrets.conf) which will be created from the key 'st2.secrets.conf' within this secret.
91-
# If this is defined, '--config-file=/etc/st2/st2.secrets.conf' will be added to the end of the command line arguments
91+
# If this is defined, '--config-file=/etc/st2/st2.secrets.conf' will be added to the end of the command line arguments
9292
# for all pods, superseding all other configuration values.
9393
# This secret must be populated outside of this chart.
9494
# existingConfigSecret: stackstorm-config-secret
@@ -919,6 +919,10 @@ jobs:
919919
# HTTP_PROXY: http://proxy:1234
920920
## These named secrets (managed outside this chart) will be added to envFrom.
921921
envFromSecrets: []
922+
# mount extra volumes on the jobs pods (primarily useful for k8s-provisioned secrets)
923+
## Note that Helm templating is supported in 'mount' and 'volume'
924+
extra_volumes: []
925+
# see examples under st2actionrunner.extra_volumes
922926
#
923927
# Advanced controls to skip creating jobs.
924928
# This is useful in targeted upgrades with `--set`. Do not set this in values files.

0 commit comments

Comments
 (0)