Skip to content

Commit d621209

Browse files
ericreevescognifloyd
authored andcommitted
Add Ability to Write/Use st2.secrets.conf from K8s Secret
1 parent 93afc57 commit d621209

File tree

6 files changed

+61
-13
lines changed

6 files changed

+61
-13
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## In Development
44
* Temporary workaround for #311 to use previous bitnami index from: https://github.com/bitnami/charts/issues/10539 (#312 #318) (by @0xhaven)
55
* Refactor label definitions to be more consistent by building labels and label selectors in partial helper templates. (#299) (by @cognifloyd)
6+
* 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)
67

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

templates/_helpers.tpl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,31 @@ Reduce duplication of the st2.*.conf volume details
124124
- name: st2-config-vol
125125
mountPath: /etc/st2/st2.user.conf
126126
subPath: st2.user.conf
127+
{{- if $.Values.st2.existingConfigSecret }}
128+
- name: st2-config-secrets-vol
129+
mountPath: /etc/st2/st2.secrets.conf
130+
subPath: st2.secrets.conf
131+
{{- end }}
127132
{{- end -}}
128133
{{- define "stackstorm-ha.st2-config-volume" -}}
129134
- name: st2-config-vol
130135
configMap:
131136
name: {{ $.Release.Name }}-st2-config
137+
{{- if $.Values.st2.existingConfigSecret }}
138+
- name: st2-config-secrets-vol
139+
secret:
140+
secretName: {{ $.Values.st2.existingConfigSecret }}
141+
{{- end }}
142+
{{- end -}}
143+
144+
# Override CMD CLI parameters passed to the startup of all pods to add support for /etc/st2/st2.secrets.conf
145+
{{- define "stackstorm-ha.st2-config-file-parameters" -}}
146+
- --config-file=/etc/st2/st2.conf
147+
- --config-file=/etc/st2/st2.docker.conf
148+
- --config-file=/etc/st2/st2.user.conf
149+
{{- if $.Values.st2.existingConfigSecret }}
150+
- --config-file=/etc/st2/st2.secrets.conf
151+
{{- end }}
132152
{{- end -}}
133153

134154
{{- define "stackstorm-ha.init-containers-wait-for-db" -}}

templates/configmaps_st2-conf.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ metadata:
77
description: Custom StackStorm config which will apply settings on top of default st2.conf
88
labels: {{- include "stackstorm-ha.labels" (list $ "st2") | nindent 4 }}
99
data:
10-
# TODO: Bundle DB/MQ login secrets in dynamic ENV-based st2.secrets.conf, leave custom user-defined settings for st2.user.conf (?)
1110
# Docker/K8s-based st2 config file used for templating service names and common overrides on top of original st2.conf.
1211
# The order of merging: st2.conf < st2.docker.conf < st2.user.conf
1312
st2.docker.conf: |

templates/deployments.yaml

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ spec:
7272
# TODO: Add liveness/readiness probes (#3)
7373
#livenessProbe:
7474
#readinessProbe:
75+
command:
76+
- /opt/stackstorm/st2/bin/st2auth
77+
{{- include "stackstorm-ha.st2-config-file-parameters" $ | nindent 10 }}
7578
{{- if .Values.st2auth.env }}
7679
env: {{- include "stackstorm-ha.customEnv" .Values.st2auth | nindent 8 }}
7780
{{- end }}
@@ -188,6 +191,9 @@ spec:
188191
# TODO: Add liveness/readiness probes (#3)
189192
#livenessProbe:
190193
#readinessProbe:
194+
command:
195+
- /opt/stackstorm/st2/bin/st2api
196+
{{- include "stackstorm-ha.st2-config-file-parameters" $ | nindent 10 }}
191197
{{- if .Values.st2api.env }}
192198
env: {{- include "stackstorm-ha.customEnv" .Values.st2api | nindent 8 }}
193199
{{- end }}
@@ -311,6 +317,9 @@ spec:
311317
# TODO: Add liveness/readiness probes (#3)
312318
#livenessProbe:
313319
#readinessProbe:
320+
command:
321+
- /opt/stackstorm/st2/bin/st2stream
322+
{{- include "stackstorm-ha.st2-config-file-parameters" $ | nindent 10 }}
314323
{{- if .Values.st2stream.env }}
315324
env: {{- include "stackstorm-ha.customEnv" .Values.st2stream | nindent 8 }}
316325
{{- end }}
@@ -540,6 +549,9 @@ spec:
540549
# TODO: Add liveness/readiness probes (#3)
541550
#livenessProbe:
542551
#readinessProbe:
552+
command:
553+
- /opt/stackstorm/st2/bin/st2rulesengine
554+
{{- include "stackstorm-ha.st2-config-file-parameters" $ | nindent 10 }}
543555
{{- if .Values.st2rulesengine.env }}
544556
env: {{- include "stackstorm-ha.customEnv" .Values.st2rulesengine | nindent 8 }}
545557
{{- end }}
@@ -654,6 +666,9 @@ spec:
654666
# TODO: Add liveness/readiness probes (#3)
655667
#livenessProbe:
656668
#readinessProbe:
669+
command:
670+
- /opt/stackstorm/st2/bin/st2timersengine
671+
{{- include "stackstorm-ha.st2-config-file-parameters" $ | nindent 10 }}
657672
{{- if .Values.st2timersengine.env }}
658673
env: {{- include "stackstorm-ha.customEnv" .Values.st2timersengine | nindent 8 }}
659674
{{- end }}
@@ -755,6 +770,9 @@ spec:
755770
# TODO: Add liveness/readiness probes (#3)
756771
#livenessProbe:
757772
#readinessProbe:
773+
command:
774+
- /opt/stackstorm/st2/bin/st2workflowengine
775+
{{- include "stackstorm-ha.st2-config-file-parameters" $ | nindent 10 }}
758776
{{- if .Values.st2workflowengine.env }}
759777
env: {{- include "stackstorm-ha.customEnv" .Values.st2workflowengine | nindent 8 }}
760778
{{- end }}
@@ -868,6 +886,9 @@ spec:
868886
# TODO: Add liveness/readiness probes (#3)
869887
#livenessProbe:
870888
#readinessProbe:
889+
command:
890+
- /opt/stackstorm/st2/bin/st2scheduler
891+
{{- include "stackstorm-ha.st2-config-file-parameters" $ | nindent 10 }}
871892
{{- if .Values.st2scheduler.env }}
872893
env: {{- include "stackstorm-ha.customEnv" .Values.st2scheduler | nindent 8 }}
873894
{{- end }}
@@ -981,6 +1002,9 @@ spec:
9811002
# TODO: Add liveness/readiness probes (#3)
9821003
#livenessProbe:
9831004
#readinessProbe:
1005+
command:
1006+
- /opt/stackstorm/st2/bin/st2notifier
1007+
{{- include "stackstorm-ha.st2-config-file-parameters" $ | nindent 10 }}
9841008
{{- if .Values.st2notifier.env }}
9851009
env: {{- include "stackstorm-ha.customEnv" .Values.st2notifier | nindent 8 }}
9861010
{{- end }}
@@ -1150,20 +1174,16 @@ spec:
11501174
livenessProbe:
11511175
{{- toYaml . | nindent 10 }}
11521176
{{- end }}
1153-
{{- if or $one_sensor_per_pod $some_sensors_per_pod }}{{/* ie: when there is more than one pod of sensors */}}
11541177
command:
11551178
- /opt/stackstorm/st2/bin/st2sensorcontainer
1156-
- --config-file=/etc/st2/st2.conf
1157-
- --config-file=/etc/st2/st2.docker.conf
1158-
- --config-file=/etc/st2/st2.user.conf
1179+
{{- include "stackstorm-ha.st2-config-file-parameters" $ | nindent 10 }}
11591180
{{- if $one_sensor_per_pod }}{{/* only in st2.packs.sensors[] */}}
11601181
- --single-sensor-mode
11611182
- --sensor-ref={{ required "You must define `ref` for everything in st2.packs.sensors. This assigns each sensor to a pod." $sensor.ref }}
11621183
{{- else if $some_sensors_per_pod }}
11631184
# injected by {{ $name }}-init-config
11641185
- --config-file=/etc/st2/st2.sensorcontainer.conf
11651186
{{- end }}
1166-
{{- end }}
11671187
{{- if $sensor.env }}
11681188
env: {{- include "stackstorm-ha.customEnv" $sensor | nindent 8 }}
11691189
{{- end }}
@@ -1308,6 +1328,9 @@ spec:
13081328
# TODO: Add liveness/readiness probes (#3)
13091329
#livenessProbe:
13101330
#readinessProbe:
1331+
command:
1332+
- /opt/stackstorm/st2/bin/st2actionrunner
1333+
{{- include "stackstorm-ha.st2-config-file-parameters" $ | nindent 10 }}
13111334
{{- if .Values.st2actionrunner.env }}
13121335
env: {{- include "stackstorm-ha.customEnv" .Values.st2actionrunner | nindent 8 }}
13131336
{{- end }}
@@ -1439,6 +1462,9 @@ spec:
14391462
# TODO: Add liveness/readiness probes (#3)
14401463
#livenessProbe:
14411464
#readinessProbe:
1465+
command:
1466+
- /opt/stackstorm/st2/bin/st2garbagecollector
1467+
{{- include "stackstorm-ha.st2-config-file-parameters" $ | nindent 10 }}
14421468
{{- if .Values.st2garbagecollector.env }}
14431469
env: {{- include "stackstorm-ha.customEnv" .Values.st2garbagecollector | nindent 8 }}
14441470
{{- end }}

templates/jobs.yaml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@ spec:
3939
command:
4040
- st2-apply-rbac-definitions
4141
- --verbose
42-
- --config-file=/etc/st2/st2.conf
43-
- --config-file=/etc/st2/st2.docker.conf
44-
- --config-file=/etc/st2/st2.user.conf
42+
{{- include "stackstorm-ha.st2-config-file-parameters" . | nindent 10 }}
4543
{{- if .Values.jobs.env }}
4644
env: {{- include "stackstorm-ha.customEnv" .Values.jobs | nindent 8 }}
4745
{{- end }}
@@ -413,9 +411,7 @@ spec:
413411
{{- end }}
414412
command:
415413
- st2-register-content
416-
- --config-file=/etc/st2/st2.conf
417-
- --config-file=/etc/st2/st2.docker.conf
418-
- --config-file=/etc/st2/st2.user.conf
414+
{{- include "stackstorm-ha.st2-config-file-parameters" . | nindent 10 }}
419415
- --register-all
420416
- --register-fail-on-failure
421417
{{- if .Values.jobs.env }}

values.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ st2:
8484
# enabled: false
8585

8686

87+
# Custom StackStorm config (st2.secret.conf) which will be created from the key 'st2.secret.conf' within this secret.
88+
# If this is defined, '--config-file=/etc/st2/st2.secrets.conf' will be added to the end of the command line arguments
89+
# for all pods, superseding all other configuration values.
90+
# This secret must be populated outside of this chart.
91+
# existingConfigSecret: stackstorm-config-secret
92+
8793
# This mirrors the [system_user] section of st2.conf, but makes the values available for helm templating.
8894
# If you change the user, you must provide a customized st2actionrunner image that includes your user.
8995
system_user:
@@ -971,7 +977,7 @@ mongodb:
971977
rootPassword: "8fAzdnksdzPFUWm4a68EfY7nMhBPaa"
972978
# Initial database for stackstorm
973979
database: "st2"
974-
# Minimal key length is 6 symbols
980+
# Minimal key length is 6 symbols and may only contain characters in the base64 set.
975981
replicaSetKey: "82PItDpqroti5RngOA7UqbHH7c6bFUwy"
976982
# Whether to enable the arbiter
977983
arbiter:

0 commit comments

Comments
 (0)