Skip to content

Commit a9e582f

Browse files
committed
Allow st2.packs.configs to work with st2.packs.volumes.configs
1 parent 938ee9e commit a9e582f

File tree

4 files changed

+31
-7
lines changed

4 files changed

+31
-7
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ For example:
215215
```
216216
Don't forget running Helm upgrade to apply new changes.
217217

218-
NOTE: `st2.packs.configs` will be ignored if you use `st2packs` images with `volumes.configs` (optional part of Method 2, described below).
218+
NOTE: On `helm upgrade` any configs in `st2.packs.configs` will overwrite the contents of `st2.packs.volumes.configs` (optional part of Method 2, described below).
219219

220220
#### Pull st2packs from a private Docker registry
221221
If you need to pull your custom packs Docker image from a private repository, create a Kubernetes Docker registry secret and pass it to Helm values.
@@ -227,7 +227,7 @@ kubectl create secret docker-registry st2packs-auth --docker-server=<your-regist
227227
Once secret created, reference its name in helm value: `st2.packs.images[].pullSecret`.
228228

229229
### Method 2: Shared Volumes
230-
This method requires cluster-specific storage setup and configuration. As the storage volumes are both writable and shared, `st2 pack install` should work like it does for standalone StackStorm installations. The volumes get mounted at `/opt/stackstorm/{packs,virtualenvs}` in the containers that need read or write access to those directories. With this method, `/opt/stackstorm/configs` can also be mounted as a writable volume instead of using `st2.packs.configs`.
230+
This method requires cluster-specific storage setup and configuration. As the storage volumes are both writable and shared, `st2 pack install` should work like it does for standalone StackStorm installations. The volumes get mounted at `/opt/stackstorm/{packs,virtualenvs}` in the containers that need read or write access to those directories. With this method, `/opt/stackstorm/configs` can also be mounted as a writable volume (in which case the contents of `st2.packs.configs` takes precedence on `helm upgrade`).
231231

232232
NOTE: With care, `st2packs` images can be used with `volumes`. Just make sure to keep the `st2packs` images up-to-date with any changes made via `st2 pack install`.
233233
If a pack is installed via an `st2packs` image and then it gets updated with `st2 pack install`, a subsequent `helm upgrade` will revert back to the version in the `st2packs` image.
@@ -269,7 +269,7 @@ You may either use the `st2.packs.configs` section of Helm values (like Method 1
269269
or add another shared writable volume similar to `packs` and `virtualenvs`. This volume gets mounted
270270
to `/opt/stackstorm/configs` instead of the `st2.packs.config` values.
271271

272-
NOTE: If you define a configs volume, anything in `st2.packs.configs` will NOT be visible to StackStorm.
272+
NOTE: If you define a configs volume and specify `st2.packs.configs`, anything in `st2.packs.configs` takes precdence during `helm upgrade`, overwriting config files already in the volume.
273273

274274
For example, to use persistentVolumeClaims:
275275
```

templates/_helpers.tpl

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@ Create the name of the stackstorm-ha service account to use
125125
{{- if and .Values.st2.packs.volumes.enabled .Values.st2.packs.volumes.configs }}
126126
- name: st2-pack-configs-vol
127127
{{ toYaml .Values.st2.packs.volumes.configs | indent 2 }}
128+
{{- if .Values.st2.packs.configs }}
129+
- name: st2-pack-configs-from-helm-vol
130+
configMap:
131+
name: {{ .Release.Name }}-st2-pack-configs
132+
{{- end }}
128133
{{- else }}
129134
- name: st2-pack-configs-vol
130135
configMap:
@@ -134,6 +139,10 @@ Create the name of the stackstorm-ha service account to use
134139
{{- define "pack-configs-volume-mount" -}}
135140
- name: st2-pack-configs-vol
136141
mountPath: /opt/stackstorm/configs/
142+
{{- if and .Values.st2.packs.volumes.enabled .Values.st2.packs.volumes.configs .Values.st2.packs.configs }}
143+
- name: st2-pack-configs-from-helm-vol
144+
mountPath: /opt/stackstorm/configs-helm/
145+
{{- end }}
137146
{{- end -}}
138147

139148
# For custom st2packs-Container reduce duplicity by defining it here once
@@ -213,6 +222,22 @@ Create the name of the stackstorm-ha service account to use
213222
/bin/cp -aR /opt/stackstorm/packs/. /opt/stackstorm/packs-shared &&
214223
/bin/cp -aR /opt/stackstorm/virtualenvs/. /opt/stackstorm/virtualenvs-shared
215224
{{- end }}
225+
{{- if and $.Values.st2.packs.configs $.Values.st2.packs.volumes.enabled }}
226+
# Pack configs defined in helm values
227+
- name: st2-pack-configs-from-helm
228+
image: '{{ template "imageRepository" . }}/st2actionrunner:{{ tpl (.Values.st2actionrunner.image.tag | default .Values.image.tag) . }}'
229+
imagePullPolicy: {{ .Values.image.pullPolicy }}
230+
volumeMounts:
231+
- name: st2-pack-configs-vol
232+
mountPath: /opt/stackstorm/configs-shared
233+
- name: st2-pack-configs-from-helm-vol
234+
mountPath: /opt/stackstorm/configs
235+
command:
236+
- 'sh'
237+
- '-ec'
238+
- |
239+
/bin/cp -aR /opt/stackstorm/configs/. /opt/stackstorm/configs-shared &&
240+
{{- end }}
216241
{{- end -}}
217242

218243

templates/configmaps_packs.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
{{- if not (and .Values.st2.packs.volumes.enabled .Values.st2.packs.volumes.configs) -}}
21
---
32
apiVersion: v1
43
kind: ConfigMap
54
metadata:
65
name: {{ .Release.Name }}-st2-pack-configs
76
annotations:
8-
description: Custom StackStorm pack configs, shipped in '/opt/stackstorm/configs/'
7+
description: StackStorm pack configs defined in helm values, shipped in (or copied to) '/opt/stackstorm/configs/'
98
labels:
109
app: st2
1110
tier: backend
@@ -15,4 +14,3 @@ metadata:
1514
heritage: {{ .Release.Service }}
1615
data:
1716
{{ toYaml .Values.st2.packs.configs | indent 2 }}
18-
{{- end -}}

values.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ st2:
8181
packs:
8282
# Custom StackStorm pack configs. Each record creates a file in '/opt/stackstorm/configs/'
8383
# https://docs.stackstorm.com/reference/pack_configs.html#configuration-file
84-
# NOTE: This is ignored if st2.packs.volumes.configs is defined and st2.packs.volumes is enabled
84+
# NOTE: This takes precedence over the contents of st2.packs.volumes.configs (if defined) on helm upgrade.
8585
configs:
8686
core.yaml: |
8787
---
@@ -141,6 +141,7 @@ st2:
141141
configs: {}
142142
# mounted to /opt/stackstorm/configs
143143
# configs volume definition is optional, but only used if st2.packs.volumes is enabled
144+
# Anything in `st2.packs.configs` will be added to this volume automatically on helm install/upgrade.
144145
# see the examples under st2.packs.volumes.packs
145146

146147
# https://docs.stackstorm.com/reference/ha.html#st2sensorcontainer

0 commit comments

Comments
 (0)