Skip to content

Commit 834c478

Browse files
authored
Merge pull request #213 from cognifloyd/register-content-init-container
Add preRegisterContentCommand in an initContainer for register-content job
2 parents 494096a + 0344a5a commit 834c478

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
* Fix permissions for /home/stanley/.ssh/stanley_rsa using the postStart lifecycle hook (#219) (by @cognifloyd)
1818
* Make system_user configurable when using custom st2actionrunner images that do not provide stanley (#220) (by @cognifloyd)
1919
* Allow providing scripts in values for use in lifecycle postStart hooks of all deployments. (#206) (by @cognifloyd)
20+
* Add preRegisterContentCommand in an initContainer for register-content job to run last-minute content customizations (#213) (by @cognifloyd)
2021

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

templates/jobs.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,22 @@ spec:
377377
{{- if $.Values.st2.packs.images -}}
378378
{{- include "packs-initContainers" . | nindent 6 }}
379379
{{ end }}
380+
{{- if $.Values.jobs.preRegisterContentCommand }}
381+
- name: st2-register-content-custom-init
382+
image: '{{ template "imageRepository" . }}/st2actionrunner:{{ tpl (.Values.jobs.image.tag | default (.Values.st2actionrunner.image.tag | default .Values.image.tag)) . }}'
383+
imagePullPolicy: {{ .Values.image.pullPolicy }}
384+
command: {{- toYaml $.Values.jobs.preRegisterContentCommand | nindent 8 }}
385+
volumeMounts:
386+
{{- include "st2-config-volume-mounts" . | nindent 8 }}
387+
- name: st2-pack-configs-vol
388+
mountPath: /opt/stackstorm/configs/
389+
{{- if .Values.st2.packs.images }}
390+
- name: st2-packs-vol
391+
mountPath: /opt/stackstorm/packs/
392+
- name: st2-virtualenvs-vol
393+
mountPath: /opt/stackstorm/virtualenvs/
394+
{{- end }}
395+
{{ end }}
380396
containers:
381397
- name: st2-register-content
382398
image: '{{ template "imageRepository" . }}/st2actionrunner:{{ tpl (.Values.jobs.image.tag | default (.Values.st2actionrunner.image.tag | default .Values.image.tag)) . }}'

values.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,9 +585,21 @@ st2chatops:
585585
jobs:
586586
annotations: {}
587587
# Override default image settings (for now, only tag can be overridden)
588+
# The Jobs use the st2actionrunner image
588589
image: {}
589590
## Note that Helm templating is supported in this block!
590591
#tag: "{{ .Values.image.tag }}"
592+
# If defined, this preRegisterContentCommand runs in an initContainer on the st2-register-content Job.
593+
# The initContainer also uses the st2actionrunner image but runs this command instead of its entrypoint.
594+
preRegisterContentCommand: []
595+
# For example, to disable aliases in the "packs" system pack before content is registered:
596+
# - "/bin/bash"
597+
# - "-c"
598+
# - |
599+
# sed -i -e 's/^\(\s*\)enabled: true/\1enabled: false/' /opt/stackstorm/packs/packs/aliases/*.yaml
600+
# for alias in /opt/stackstorm/packs/packs/aliases/*.yaml; do
601+
# grep -q 'enabled:' ${alias} || sed -i -e 's/^\(\s*\)name:\(.*\)$/\1name: \2\n\1enabled: false/m' ${alias}
602+
# done
591603
# Additional advanced settings to control pod/deployment placement
592604
nodeSelector: {}
593605
tolerations: []

0 commit comments

Comments
 (0)