Skip to content

Commit eb061b9

Browse files
authored
Merge pull request #259 from cognifloyd/envfromsecrets
add envFromSecrets for action, sensor, client, jobs pods
2 parents cbde210 + 7b0ec4a commit eb061b9

File tree

4 files changed

+44
-0
lines changed

4 files changed

+44
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* 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)
1111
* Some `helm upgrades` do not need to run all the jobs. An upgrade that only touches RBAC config, for example, does not need to run the register-content job. Use `--set 'jobs.skip={apikey_load,key_load,register_content}'` to skip the other jobs. (#255) (by @cognifloyd)
1212
* Refactor deployments/jobs to inject st2 username/password via `envFrom` instead of via `env`. (#257) (by @cognifloyd)
13+
* New feature: Add `envFromSecrets` to `st2actionrunner`, `st2client`, `st2sensorcontainer`, and jobs. This is useful for adding custom secrets to the environment. This complements the `extra_volumes` feature (loading secrets as files) to facilitate loading secrets that are not easily injected via the filesystem. (#259) (by @cognifloyd)
1314

1415
## v0.70.0
1516
* 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: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,6 +1116,10 @@ spec:
11161116
envFrom:
11171117
- configMapRef:
11181118
name: {{ $.Release.Name }}-st2-urls
1119+
{{- range $sensor.envFromSecrets }}
1120+
- secretRef:
1121+
name: {{ . }}
1122+
{{- end }}
11191123
volumeMounts:
11201124
{{- include "st2-config-volume-mounts" $ | nindent 8 }}
11211125
{{- include "packs-volume-mounts" $ | nindent 8 }}
@@ -1250,6 +1254,10 @@ spec:
12501254
envFrom:
12511255
- configMapRef:
12521256
name: {{ .Release.Name }}-st2-urls
1257+
{{- range .Values.st2actionrunner.envFromSecrets }}
1258+
- secretRef:
1259+
name: {{ . }}
1260+
{{- end }}
12531261
volumeMounts:
12541262
{{- include "st2-config-volume-mounts" . | nindent 8 }}
12551263
- name: st2-ssh-key-vol
@@ -1506,6 +1514,10 @@ spec:
15061514
envFrom:
15071515
- configMapRef:
15081516
name: {{ .Release.Name }}-st2-urls
1517+
{{- range .Values.st2client.envFromSecrets }}
1518+
- secretRef:
1519+
name: {{ . }}
1520+
{{- end }}
15091521
volumeMounts:
15101522
{{- include "st2-config-volume-mounts" . | nindent 8 }}
15111523
{{- if .Values.st2.rbac.enabled }}

templates/jobs.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ spec:
5151
{{- if .Values.jobs.env }}
5252
env: {{- include "stackstorm-ha.customEnv" .Values.jobs | nindent 8 }}
5353
{{- end }}
54+
{{- if .Values.jobs.envFromSecrets }}
55+
envFrom:
56+
{{- range .Values.jobs.envFromSecrets }}
57+
- secretRef:
58+
name: {{ . }}
59+
{{- end }}
60+
{{- end }}
5461
volumeMounts:
5562
{{- include "st2-config-volume-mounts" . | nindent 8 }}
5663
- name: st2-rbac-roles-vol
@@ -178,6 +185,10 @@ spec:
178185
envFrom:
179186
- configMapRef:
180187
name: {{ .Release.Name }}-st2-urls
188+
{{- range .Values.jobs.envFromSecrets }}
189+
- secretRef:
190+
name: {{ . }}
191+
{{- end }}
181192
volumeMounts:
182193
- name: st2client-config-vol
183194
mountPath: /root/.st2/
@@ -291,6 +302,10 @@ spec:
291302
envFrom:
292303
- configMapRef:
293304
name: {{ .Release.Name }}-st2-urls
305+
{{- range .Values.jobs.envFromSecrets }}
306+
- secretRef:
307+
name: {{ . }}
308+
{{- end }}
294309
volumeMounts:
295310
{{- include "st2-config-volume-mounts" . | nindent 8 }}
296311
- name: st2client-config-vol
@@ -402,6 +417,13 @@ spec:
402417
{{- if .Values.jobs.env }}
403418
env: {{- include "stackstorm-ha.customEnv" .Values.jobs | nindent 8 }}
404419
{{- end }}
420+
{{- if .Values.jobs.envFromSecrets }}
421+
envFrom:
422+
{{- range .Values.jobs.envFromSecrets }}
423+
- secretRef:
424+
name: {{ . }}
425+
{{- end }}
426+
{{- end }}
405427
volumeMounts:
406428
{{- include "st2-config-volume-mounts" . | nindent 8 }}
407429
{{- include "packs-volume-mounts-for-register-job" . | nindent 8 }}

values.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,8 @@ st2actionrunner:
546546
# ip: 8.8.8.8
547547
env: {}
548548
# HTTP_PROXY: http://proxy:1234
549+
## These named secrets (managed outside this chart) will be added to envFrom.
550+
envFromSecrets: []
549551
serviceAccount:
550552
attach: false
551553
# postStartScript is optional. It has the contents of a bash script.
@@ -604,6 +606,8 @@ st2sensorcontainer:
604606
tolerations: []
605607
env: {}
606608
# HTTP_PROXY: http://proxy:1234
609+
## These named secrets (managed outside this chart) will be added to envFrom.
610+
envFromSecrets: []
607611
serviceAccount:
608612
attach: false
609613
# postStartScript is optional. It has the contents of a bash script.
@@ -621,6 +625,8 @@ st2sensorcontainer:
621625
st2client:
622626
env: {}
623627
# HTTP_PROXY: http://proxy:1234
628+
## These named secrets (managed outside this chart) will be added to envFrom.
629+
envFromSecrets: []
624630
annotations: {}
625631
# Override default image settings (for now, only tag can be overridden)
626632
image: {}
@@ -673,6 +679,7 @@ st2chatops:
673679
# Enable st2chatops (default: false)
674680
enabled: false
675681
# Custom hubot adapter ENV variables to pass through which will override st2chatops.env defaults.
682+
# These env vars get stored in a k8s secret loaded using envFrom.
676683
# See https://github.com/StackStorm/st2chatops/blob/master/st2chatops.env
677684
# for the full list of supported adapters and example ENV variables.
678685
# Note that Helm templating is supported for env values in this block!
@@ -741,6 +748,8 @@ jobs:
741748
affinity: {}
742749
env: {}
743750
# HTTP_PROXY: http://proxy:1234
751+
## These named secrets (managed outside this chart) will be added to envFrom.
752+
envFromSecrets: []
744753
#
745754
# Advanced controls to skip creating jobs.
746755
# This is useful in targeted upgrades with `--set`. Do not set this in values files.

0 commit comments

Comments
 (0)