Skip to content

Commit 677d15a

Browse files
authored
Merge pull request #254 from cognifloyd/actionrunner-custom-volumes
Feature: custom volumes (for secrets, etc) on st2actionrunner pods
2 parents e668e69 + 818e1c8 commit 677d15a

File tree

3 files changed

+71
-0
lines changed

3 files changed

+71
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* Set default/sample RBAC config files to "" (empty string) to prevent adding them. This is needed because they cannot be removed by overriding the roles/mappings values. (#247) (by @cognifloyd)
88
* Make configuring `stackstorm/sensor-mode=all-sensors-in-one-pod` more obvious by using `st2.packs.sensors` only for `one-sensor-per-pod`. `all-sensors-in-one-pod` mode now only uses values from `st2sensorcontainer`. (#246) (by @cognifloyd)
99
* Use "--convert" when loading keys into datastore (in key-load Job) so that `st2.keyvalue[].value` can be any basic JSON data type. (#253) (by @cognifloyd)
10+
* New feature: Add `extra_volumes` to `st2actionrunner`, `st2client`, `st2sensorcontainer`. This is useful for loading volumes to be used by actions or sensors. This might include secrets (like ssl certificates) and configuration (like system-wide ansible.cfg). (#254) (by @cognifloyd)
1011

1112
## v0.70.0
1213
* New feature: Shared packs volumes `st2.packs.volumes`. Allow using cluster-specific persistent volumes to store packs, virtualenvs, and (optionally) configs. This enables using `st2 pack install`. It even works with `st2packs` images in `st2.packs.images`. (#199) (by @cognifloyd)

templates/deployments.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,10 @@ spec:
764764
mountPath: /etc/st2/keys
765765
readOnly: true
766766
{{- end }}
767+
{{- range .Values.st2workflowengine.extra_volumes }}
768+
- name: {{ required "Each volume must have a 'name' in st2workflowengine.extra_volumes" .name }}
769+
{{- tpl (required "Each volume must have a 'mount' definition in st2workflowengine.extra_volumes" .mount | toYaml) $ | nindent 10 }}
770+
{{- end }}
767771
{{- if .Values.st2workflowengine.postStartScript }}
768772
- name: st2-post-start-script-vol
769773
mountPath: /post-start.sh
@@ -788,6 +792,10 @@ spec:
788792
- key: datastore_crypto_key
789793
path: datastore_key.json
790794
{{- end }}
795+
{{- range .Values.st2workflowengine.extra_volumes }}
796+
- name: {{ required "Each volume must have a 'name' in st2workflowengine.extra_volumes" .name }}
797+
{{- tpl (required "Each volume must have a 'volume' definition in st2workflowengine.extra_volumes" .volume | toYaml) $ | nindent 10 }}
798+
{{- end }}
791799
{{- if .Values.st2workflowengine.postStartScript }}
792800
- name: st2-post-start-script-vol
793801
configMap:
@@ -1124,6 +1132,10 @@ spec:
11241132
mountPath: /etc/st2/keys
11251133
readOnly: true
11261134
{{- end }}
1135+
{{- range $sensor.extra_volumes }}
1136+
- name: {{ required "Each volume must have a 'name' in $sensor.extra_volumes" .name }}
1137+
{{- tpl (required "Each volume must have a 'mount' definition in $sensor.extra_volumes" .mount | toYaml) $ | nindent 10 }}
1138+
{{- end }}
11271139
{{- if $.Values.st2sensorcontainer.postStartScript }}
11281140
- name: st2-post-start-script-vol
11291141
mountPath: /post-start.sh
@@ -1149,6 +1161,10 @@ spec:
11491161
{{- end }}
11501162
{{- include "st2-config-volume" $ | nindent 8 }}
11511163
{{- include "packs-volumes" $ | nindent 8 }}
1164+
{{- range $sensor.extra_volumes }}
1165+
- name: {{ required "Each volume must have a 'name' in $sensor.extra_volumes" .name }}
1166+
{{- tpl (required "Each volume must have a 'volume' definition in $sensor.extra_volumes" .volume | toYaml) $ | nindent 10 }}
1167+
{{- end }}
11521168
{{- if $.Values.st2sensorcontainer.postStartScript }}
11531169
- name: st2-post-start-script-vol
11541170
configMap:
@@ -1255,6 +1271,10 @@ spec:
12551271
{{- if .Values.st2.packs.volumes.enabled }}
12561272
{{- include "pack-configs-volume-mount" . | nindent 8 }}
12571273
{{- end }}
1274+
{{- range .Values.st2actionrunner.extra_volumes }}
1275+
- name: {{ required "Each volume must have a 'name' in st2actionrunner.extra_volumes" .name }}
1276+
{{- tpl (required "Each volume must have a 'mount' definition in st2actionrunner.extra_volumes" .mount | toYaml) $ | nindent 10 }}
1277+
{{- end }}
12581278
- name: st2-post-start-script-vol
12591279
mountPath: /post-start.sh
12601280
subPath: post-start.sh
@@ -1289,6 +1309,10 @@ spec:
12891309
{{- if .Values.st2.packs.volumes.enabled }}
12901310
{{- include "pack-configs-volume" . | nindent 8 }}
12911311
{{- end }}
1312+
{{- range .Values.st2actionrunner.extra_volumes }}
1313+
- name: {{ required "Each volume must have a 'name' in st2actionrunner.extra_volumes" .name }}
1314+
{{- tpl (required "Each volume must have a 'volume' definition in st2actionrunner.extra_volumes" .volume | toYaml) $ | nindent 10 }}
1315+
{{- end }}
12921316
- name: st2-post-start-script-vol
12931317
configMap:
12941318
name: {{ .Release.Name }}-st2actionrunner-post-start-script
@@ -1520,6 +1544,10 @@ spec:
15201544
{{- end }}
15211545
{{- include "packs-volume-mounts" . | nindent 8 }}
15221546
{{- include "pack-configs-volume-mount" . | nindent 8 }}
1547+
{{- range .Values.st2client.extra_volumes }}
1548+
- name: {{ required "Each volume must have a 'name' in st2client.extra_volumes" .name }}
1549+
{{- tpl (required "Each volume must have a 'mount' definition in st2client.extra_volumes" .mount | toYaml) $ | nindent 10 }}
1550+
{{- end }}
15231551
- name: st2-post-start-script-vol
15241552
mountPath: /post-start.sh
15251553
subPath: post-start.sh
@@ -1569,6 +1597,10 @@ spec:
15691597
mode: 256
15701598
{{- include "packs-volumes" . | nindent 8 }}
15711599
{{- include "pack-configs-volume" . | nindent 8 }}
1600+
{{- range .Values.st2client.extra_volumes }}
1601+
- name: {{ required "Each volume must have a 'name' in st2client.extra_volumes" .name }}
1602+
{{- tpl (required "Each volume must have a 'volume' definition in st2client.extra_volumes" .volume | toYaml) $ | nindent 10 }}
1603+
{{- end }}
15721604
- name: st2-post-start-script-vol
15731605
configMap:
15741606
name: {{ .Release.Name }}-st2client-post-start-script

values.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,10 @@ st2workflowengine:
461461
# The pod will not be marked as "running" until this script completes successfully.
462462
# see: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/
463463
postStartScript: ""
464+
# mount extra volumes on the st2workflowengine pod(s) (primarily useful for k8s-provisioned secrets)
465+
## Note that Helm templating is supported in 'mount' and 'volume'
466+
extra_volumes: []
467+
# see examples under st2workflowengine.extra_volumes
464468
# https://docs.stackstorm.com/reference/ha.html#st2scheduler
465469
# TODO: Description TBD
466470
st2scheduler:
@@ -549,6 +553,32 @@ st2actionrunner:
549553
# The pod will not be marked as "running" until this script completes successfully.
550554
# see: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/
551555
postStartScript: ""
556+
# mount extra volumes on the st2actionrunner pods (primarily useful for k8s-provisioned secrets)
557+
## Note that Helm templating is supported in 'mount' and 'volume'
558+
extra_volumes: []
559+
# For example, if some actions in the fictional acme pack
560+
# needed some file-based client-side certificates:
561+
# - name: st2-encryption-key-vol
562+
# mount:
563+
# mountPath: "{{ .Values.acme.ssl_certs_dir }}"
564+
# readOnly: true
565+
# volume:
566+
# secret:
567+
# secretName: "{{ .Release.Name }}-st2-acme-pack-certs"
568+
# items:
569+
# - key: ssl_certificate
570+
# path: acme.crt
571+
# - key: ssl_certificate_key
572+
# path: acme.key
573+
#
574+
# An example that adds a global ansible.cfg file for the ansible pack.
575+
# - name: global-ansible-config
576+
# mount:
577+
# mountPath: /etc/ansible/ansible.cfg
578+
# subPath: ansible.cfg
579+
# volume:
580+
# configMap:
581+
# name: "{{ .Release.Name }}-st2-ansible-config"
552582

553583
# https://docs.stackstorm.com/reference/ha.html#st2sensorcontainer
554584
# It is possible to run st2sensorcontainer(s) in one of these modes:
@@ -581,6 +611,10 @@ st2sensorcontainer:
581611
# The pod will not be marked as "running" until this script completes successfully.
582612
# see: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/
583613
postStartScript: ""
614+
# mount extra volumes on the st2sensorcontainer pod(s) (primarily useful for k8s-provisioned secrets)
615+
## Note that Helm templating is supported in 'mount' and 'volume'
616+
extra_volumes: []
617+
# see examples under st2actionrunner.extra_volumes
584618

585619
# The st2client deployment/pod simplifies ad-hoc administration.
586620
# st2client is a special purpose actionrunner pod, but you can customize it separately
@@ -597,6 +631,10 @@ st2client:
597631
# The pod will not be marked as "running" until this script completes successfully.
598632
# see: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/
599633
postStartScript: ""
634+
# mount extra volumes on the st2client pod (primarily useful for k8s-provisioned secrets)
635+
## Note that Helm templating is supported in 'mount' and 'volume'
636+
extra_volumes: []
637+
# see examples under st2actionrunner.extra_volumes
600638

601639
# https://docs.stackstorm.com/reference/ha.html#st2garbagecollector
602640
# Optional service that cleans up old executions and other operations data based on setup configurations.

0 commit comments

Comments
 (0)