Skip to content

Commit a2a9e1c

Browse files
authored
Merge pull request #319 from StackStorm/optional_secret_config
Add Ability to Write/Use st2.secrets.conf from K8s Secret
2 parents 806ef07 + cc94bd0 commit a2a9e1c

File tree

8 files changed

+737
-28
lines changed

8 files changed

+737
-28
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* Fix bug that hung an init container when `st2.packs.volumes.enabled` without `st2.packs.volumes.configs`. (#324) (by @rebrowning)
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)
12+
* 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)
1213

1314
## v0.100.0
1415
* 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
@@ -131,11 +131,31 @@ Reduce duplication of the st2.*.conf volume details
131131
- name: st2-config-vol
132132
mountPath: /etc/st2/st2.user.conf
133133
subPath: st2.user.conf
134+
{{- if $.Values.st2.existingConfigSecret }}
135+
- name: st2-config-secrets-vol
136+
mountPath: /etc/st2/st2.secrets.conf
137+
subPath: st2.secrets.conf
138+
{{- end }}
134139
{{- end -}}
135140
{{- define "stackstorm-ha.st2-config-volume" -}}
136141
- name: st2-config-vol
137142
configMap:
138143
name: {{ $.Release.Name }}-st2-config
144+
{{- if $.Values.st2.existingConfigSecret }}
145+
- name: st2-config-secrets-vol
146+
secret:
147+
secretName: {{ $.Values.st2.existingConfigSecret }}
148+
{{- end }}
149+
{{- end -}}
150+
151+
# Override CMD CLI parameters passed to the startup of all pods to add support for /etc/st2/st2.secrets.conf
152+
{{- define "stackstorm-ha.st2-config-file-parameters" -}}
153+
- --config-file=/etc/st2/st2.conf
154+
- --config-file=/etc/st2/st2.docker.conf
155+
- --config-file=/etc/st2/st2.user.conf
156+
{{- if $.Values.st2.existingConfigSecret }}
157+
- --config-file=/etc/st2/st2.secrets.conf
158+
{{- end }}
139159
{{- end -}}
140160

141161
{{- 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 }}
@@ -1313,6 +1333,9 @@ spec:
13131333
# TODO: Add liveness/readiness probes (#3)
13141334
#livenessProbe:
13151335
#readinessProbe:
1336+
command:
1337+
- /opt/stackstorm/st2/bin/st2actionrunner
1338+
{{- include "stackstorm-ha.st2-config-file-parameters" $ | nindent 10 }}
13161339
{{- if .Values.st2actionrunner.env }}
13171340
env: {{- include "stackstorm-ha.customEnv" .Values.st2actionrunner | nindent 8 }}
13181341
{{- end }}
@@ -1444,6 +1467,9 @@ spec:
14441467
# TODO: Add liveness/readiness probes (#3)
14451468
#livenessProbe:
14461469
#readinessProbe:
1470+
command:
1471+
- /opt/stackstorm/st2/bin/st2garbagecollector
1472+
{{- include "stackstorm-ha.st2-config-file-parameters" $ | nindent 10 }}
14471473
{{- if .Values.st2garbagecollector.env }}
14481474
env: {{- include "stackstorm-ha.customEnv" .Values.st2garbagecollector | nindent 8 }}
14491475
{{- 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 }}
@@ -408,9 +406,7 @@ spec:
408406
{{- end }}
409407
command:
410408
- st2-register-content
411-
- --config-file=/etc/st2/st2.conf
412-
- --config-file=/etc/st2/st2.docker.conf
413-
- --config-file=/etc/st2/st2.user.conf
409+
{{- include "stackstorm-ha.st2-config-file-parameters" . | nindent 10 }}
414410
- --register-all
415411
- --register-fail-on-failure
416412
{{- if .Values.jobs.env }}

0 commit comments

Comments
 (0)