diff --git a/CHANGELOG.md b/CHANGELOG.md index 6fdc8c11..1294db0e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/templates/_helpers.tpl b/templates/_helpers.tpl index cc7a9eef..4f4abcb4 100644 --- a/templates/_helpers.tpl +++ b/templates/_helpers.tpl @@ -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 -}} diff --git a/templates/deployments.yaml b/templates/deployments.yaml index f95f6684..f6e0d4f9 100644 --- a/templates/deployments.yaml +++ b/templates/deployments.yaml @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/templates/jobs.yaml b/templates/jobs.yaml index c4250785..100df8c0 100644 --- a/templates/jobs.yaml +++ b/templates/jobs.yaml @@ -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 @@ -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 @@ -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 @@ -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 }} diff --git a/values.yaml b/values.yaml index 48ca62f6..412a512c 100644 --- a/values.yaml +++ b/values.yaml @@ -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. @@ -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 @@ -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. @@ -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. @@ -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. @@ -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. @@ -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. @@ -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. @@ -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. @@ -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. @@ -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. @@ -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. @@ -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: {} @@ -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. @@ -675,6 +703,8 @@ jobs: nodeSelector: {} tolerations: [] affinity: {} + env: {} + # HTTP_PROXY: http://proxy:1234 ## ## MongoDB HA configuration (3rd party chart dependency)