Skip to content

Commit

Permalink
Merge pull request #120 from AngryDeveloper/env-injection
Browse files Browse the repository at this point in the history
Allow injection of env vars in any deployment
  • Loading branch information
cognifloyd authored Sep 12, 2021
2 parents 05431e8 + 291d37d commit 718d769
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## In Development
* Explicitly differentiate sensor modes: `all-sensors-in-one-pod` vs `one-sensor-per-pod`. Exposes the mode in new `stackstorm/sensor-mode` annotation. (#222) (by @cognifloyd)
* Allow adding custom env variables to any Deployment or Job. (#120) (by @AngryDeveloper)

## v0.70.0
* 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)
Expand Down
10 changes: 10 additions & 0 deletions templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,13 @@ Create the name of the stackstorm-ha service account to use
{{- end }}
{{- end }}
{{- end -}}

{{/*
Create the custom env list for each deployment
*/}}
{{- define "stackstorm-ha.customEnv" -}}
{{- range $env, $value := .env }}
- name: {{ $env | quote }}
value: {{ $value | quote }}
{{- end }}
{{- end -}}
37 changes: 37 additions & 0 deletions templates/deployments.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ spec:
# TODO: Add liveness/readiness probes (#3)
#livenessProbe:
#readinessProbe:
{{- if .Values.st2auth.env }}
env: {{- include "stackstorm-ha.customEnv" .Values.st2auth | nindent 8 }}
{{- end }}
envFrom:
- configMapRef:
name: {{ .Release.Name }}-st2-urls
Expand Down Expand Up @@ -195,6 +198,9 @@ spec:
# TODO: Add liveness/readiness probes (#3)
#livenessProbe:
#readinessProbe:
{{- if .Values.st2api.env }}
env: {{- include "stackstorm-ha.customEnv" .Values.st2api | nindent 8 }}
{{- end }}
envFrom:
- configMapRef:
name: {{ .Release.Name }}-st2-urls
Expand Down Expand Up @@ -312,6 +318,9 @@ spec:
# TODO: Add liveness/readiness probes (#3)
#livenessProbe:
#readinessProbe:
{{- if .Values.st2stream.env }}
env: {{- include "stackstorm-ha.customEnv" .Values.st2stream | nindent 8 }}
{{- end }}
envFrom:
- configMapRef:
name: {{ .Release.Name }}-st2-urls
Expand Down Expand Up @@ -418,6 +427,9 @@ spec:
# path: /api/
# port: 443
# initialDelaySeconds: 3
{{- if .Values.st2web.env }}
env: {{- include "stackstorm-ha.customEnv" .Values.st2web | nindent 8 }}
{{- end }}
envFrom:
- configMapRef:
name: {{ .Release.Name }}-st2-urls
Expand Down Expand Up @@ -530,6 +542,9 @@ spec:
# TODO: Add liveness/readiness probes (#3)
#livenessProbe:
#readinessProbe:
{{- if .Values.st2rulesengine.env }}
env: {{- include "stackstorm-ha.customEnv" .Values.st2rulesengine | nindent 8 }}
{{- end }}
envFrom:
- configMapRef:
name: {{ .Release.Name }}-st2-urls
Expand Down Expand Up @@ -638,6 +653,9 @@ spec:
# TODO: Add liveness/readiness probes (#3)
#livenessProbe:
#readinessProbe:
{{- if .Values.st2timersengine.env }}
env: {{- include "stackstorm-ha.customEnv" .Values.st2timersengine | nindent 8 }}
{{- end }}
envFrom:
- configMapRef:
name: {{ .Release.Name }}-st2-urls
Expand Down Expand Up @@ -733,6 +751,9 @@ spec:
# TODO: Add liveness/readiness probes (#3)
#livenessProbe:
#readinessProbe:
{{- if .Values.st2workflowengine.env }}
env: {{- include "stackstorm-ha.customEnv" .Values.st2workflowengine | nindent 8 }}
{{- end }}
envFrom:
- configMapRef:
name: {{ .Release.Name }}-st2-urls
Expand Down Expand Up @@ -840,6 +861,9 @@ spec:
# TODO: Add liveness/readiness probes (#3)
#livenessProbe:
#readinessProbe:
{{- if .Values.st2scheduler.env }}
env: {{- include "stackstorm-ha.customEnv" .Values.st2scheduler | nindent 8 }}
{{- end }}
envFrom:
- configMapRef:
name: {{ .Release.Name }}-st2-urls
Expand Down Expand Up @@ -947,6 +971,9 @@ spec:
# TODO: Add liveness/readiness probes (#3)
#livenessProbe:
#readinessProbe:
{{- if .Values.st2notifier.env }}
env: {{- include "stackstorm-ha.customEnv" .Values.st2notifier | nindent 8 }}
{{- end }}
envFrom:
- configMapRef:
name: {{ .Release.Name }}-st2-urls
Expand Down Expand Up @@ -1081,6 +1108,9 @@ spec:
- --single-sensor-mode
- --sensor-ref={{ $sensor.ref }}
{{- end }}
{{- if .env }}
env: {{- include "stackstorm-ha.customEnv" . | nindent 8 }}
{{- end }}
envFrom:
- configMapRef:
name: {{ $.Release.Name }}-st2-urls
Expand Down Expand Up @@ -1204,6 +1234,9 @@ spec:
# TODO: Add liveness/readiness probes (#3)
#livenessProbe:
#readinessProbe:
{{- if .Values.st2actionrunner.env }}
env: {{- include "stackstorm-ha.customEnv" .Values.st2actionrunner | nindent 8 }}
{{- end }}
envFrom:
- configMapRef:
name: {{ .Release.Name }}-st2-urls
Expand Down Expand Up @@ -1325,6 +1358,9 @@ spec:
# TODO: Add liveness/readiness probes (#3)
#livenessProbe:
#readinessProbe:
{{- if .Values.st2garbagecollector.env }}
env: {{- include "stackstorm-ha.customEnv" .Values.st2garbagecollector | nindent 8 }}
{{- end }}
envFrom:
- configMapRef:
name: {{ .Release.Name }}-st2-urls
Expand Down Expand Up @@ -1457,6 +1493,7 @@ spec:
env:
- name: ST2CLIENT
value: "1"
{{- include "stackstorm-ha.customEnv" .Values.st2client | nindent 8 }}
envFrom:
- configMapRef:
name: {{ .Release.Name }}-st2-urls
Expand Down
12 changes: 12 additions & 0 deletions templates/jobs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ spec:
- --config-file=/etc/st2/st2.conf
- --config-file=/etc/st2/st2.docker.conf
- --config-file=/etc/st2/st2.user.conf
{{- if .Values.jobs.env }}
env: {{- include "stackstorm-ha.customEnv" .Values.jobs | nindent 8 }}
{{- end }}
volumeMounts:
{{- include "st2-config-volume-mounts" . | nindent 8 }}
- name: st2-rbac-roles-vol
Expand Down Expand Up @@ -177,6 +180,9 @@ spec:
- apikey
- load
- /etc/st2/apikeys.yaml
{{- if .Values.jobs.env }}
env: {{- include "stackstorm-ha.customEnv" .Values.jobs | nindent 8 }}
{{- end }}
envFrom:
- configMapRef:
name: {{ .Release.Name }}-st2-urls
Expand Down Expand Up @@ -293,6 +299,9 @@ spec:
- key
- load
- /etc/st2/st2kv.yaml
{{- if .Values.jobs.env }}
env: {{- include "stackstorm-ha.customEnv" .Values.jobs | nindent 8 }}
{{- end }}
envFrom:
- configMapRef:
name: {{ .Release.Name }}-st2-urls
Expand Down Expand Up @@ -402,6 +411,9 @@ spec:
- --config-file=/etc/st2/st2.user.conf
- --register-all
- --register-fail-on-failure
{{- if .Values.jobs.env }}
env: {{- include "stackstorm-ha.customEnv" .Values.jobs | nindent 8 }}
{{- end }}
volumeMounts:
{{- include "st2-config-volume-mounts" . | nindent 8 }}
{{- include "packs-volume-mounts-for-register-job" . | nindent 8 }}
Expand Down
30 changes: 30 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ st2:
affinity: {}
nodeSelector: {}
tolerations: []
env: {}
# HTTP_PROXY: http://proxy:1234
serviceAccount:
attach: false
# note: postStartScript is not valid here. Use st2sensorcontainer.postStartScript instead.
Expand Down Expand Up @@ -297,6 +299,8 @@ st2web:
nodeSelector: {}
tolerations: []
affinity: {}
env: {}
# HTTP_PROXY: http://proxy:1234
serviceAccount:
attach: false
# User-defined st2web config with custom settings to replace default config.js
Expand Down Expand Up @@ -325,6 +329,8 @@ st2auth:
nodeSelector: {}
tolerations: []
affinity: {}
env: {}
# HTTP_PROXY: http://proxy:1234
serviceAccount:
attach: false
# postStartScript is optional. It has the contents of a bash script.
Expand All @@ -349,6 +355,8 @@ st2api:
nodeSelector: {}
tolerations: []
affinity: {}
env: {}
# HTTP_PROXY: http://proxy:1234
serviceAccount:
attach: false
# postStartScript is optional. It has the contents of a bash script.
Expand All @@ -373,6 +381,8 @@ st2stream:
nodeSelector: {}
tolerations: []
affinity: {}
env: {}
# HTTP_PROXY: http://proxy:1234
serviceAccount:
attach: false
# postStartScript is optional. It has the contents of a bash script.
Expand All @@ -397,6 +407,8 @@ st2rulesengine:
nodeSelector: {}
tolerations: []
affinity: {}
env: {}
# HTTP_PROXY: http://proxy:1234
serviceAccount:
attach: false
# postStartScript is optional. It has the contents of a bash script.
Expand All @@ -420,6 +432,8 @@ st2timersengine:
nodeSelector: {}
tolerations: []
affinity: {}
env: {}
# HTTP_PROXY: http://proxy:1234
serviceAccount:
attach: false
# postStartScript is optional. It has the contents of a bash script.
Expand All @@ -444,6 +458,8 @@ st2workflowengine:
nodeSelector: {}
tolerations: []
affinity: {}
env: {}
# HTTP_PROXY: http://proxy:1234
serviceAccount:
attach: false
# postStartScript is optional. It has the contents of a bash script.
Expand All @@ -468,6 +484,8 @@ st2scheduler:
nodeSelector: {}
tolerations: []
affinity: {}
env: {}
# HTTP_PROXY: http://proxy:1234
serviceAccount:
attach: false
# postStartScript is optional. It has the contents of a bash script.
Expand All @@ -492,6 +510,8 @@ st2notifier:
nodeSelector: {}
tolerations: []
affinity: {}
env: {}
# HTTP_PROXY: http://proxy:1234
serviceAccount:
attach: false
# postStartScript is optional. It has the contents of a bash script.
Expand Down Expand Up @@ -526,6 +546,8 @@ st2actionrunner:
# - hostnames:
# - bar
# ip: 8.8.8.8
env: {}
# HTTP_PROXY: http://proxy:1234
serviceAccount:
attach: false
# postStartScript is optional. It has the contents of a bash script.
Expand Down Expand Up @@ -553,6 +575,8 @@ st2sensorcontainer:
affinity: {}
nodeSelector: {}
tolerations: []
env: {}
# HTTP_PROXY: http://proxy:1234
serviceAccount:
attach: false
# postStartScript is optional. It has the contents of a bash script.
Expand All @@ -564,6 +588,8 @@ st2sensorcontainer:
# The st2client deployment/pod simplifies ad-hoc administration.
# st2client is a special purpose actionrunner pod, but you can customize it separately
st2client:
env: {}
# HTTP_PROXY: http://proxy:1234
annotations: {}
# Override default image settings (for now, only tag can be overridden)
image: {}
Expand Down Expand Up @@ -594,6 +620,8 @@ st2garbagecollector:
nodeSelector: {}
tolerations: []
affinity: {}
env: {}
# HTTP_PROXY: http://proxy:1234
serviceAccount:
attach: false
# postStartScript is optional. It has the contents of a bash script.
Expand Down Expand Up @@ -675,6 +703,8 @@ jobs:
nodeSelector: {}
tolerations: []
affinity: {}
env: {}
# HTTP_PROXY: http://proxy:1234

##
## MongoDB HA configuration (3rd party chart dependency)
Expand Down

0 comments on commit 718d769

Please sign in to comment.