Skip to content

Commit

Permalink
feat: add support for deploymentStage, progressDeadlineSeconds, and h…
Browse files Browse the repository at this point in the history
…ierarchical env vars
  • Loading branch information
hspitzley-czi committed Jun 25, 2024
1 parent 265194e commit 5af70f1
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 16 deletions.
12 changes: 8 additions & 4 deletions stack/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,14 @@ envFrom:
{{- end }}

{{- define "service.nonsensitiveEnvVars" -}}
{{- if .Values.env }}
{{- $envs := list }}
{{- range $i, $envHolder := . -}}
{{ $envs = concat $envs (default (list) $envHolder.env) }}
{{- end -}}
{{- if ne (len $envs) 0 -}}
env:
{{ toYaml .Values.env }}
{{- else }}
{{ toYaml (uniq $envs) }}
{{- else -}}
env: []
{{- end }}
{{- end }}
Expand All @@ -127,4 +131,4 @@ image: {{ .Values.image }}
{{ else }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
{{- end }}
{{- end }}
{{- end }}
3 changes: 3 additions & 0 deletions stack/templates/context_configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@ metadata:
data:
__ARGUS_STACK_NAME: {{ $global.Release.Name }}
__ARGUS_STACK_INGRESS_HOST: {{ .ingress.host }}
{{- if .deploymentStage }}
__ARGUS_DEPLOYMENT_STAGE: {{ .deploymentStage }}
{{- end }}
{{- end }}
{{- end }}
6 changes: 1 addition & 5 deletions stack/templates/cronjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,7 @@ spec:
resources:
{{- toYaml .Values.resources | nindent 14 }}
{{- include "service.configuration" . | nindent 12 }}
{{- $env := concat $global.Values.global.env (fromYaml (include "service.nonsensitiveEnvVars" .)).env }}
{{- if $env }}
env:
{{- toYaml (uniq $env) | nindent 14 }}
{{- end }}
{{- include "service.nonsensitiveEnvVars" (list $global.Values.global $cronJob.Values) | nindent 12 }}
restartPolicy: OnFailure
{{- with .Values.nodeSelector }}
nodeSelector:
Expand Down
13 changes: 6 additions & 7 deletions stack/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
progressDeadlineSeconds: {{ .Values.progressDeadlineSeconds }}
revisionHistoryLimit: 3
selector:
matchLabels:
Expand Down Expand Up @@ -75,25 +76,23 @@ spec:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- include "service.configuration" . | nindent 10}}
{{- $env := concat $global.Values.global.env (fromYaml (include "service.nonsensitiveEnvVars" .)).env }}
{{- if $env }}
env:
{{- toYaml (uniq $env) | nindent 12}}
{{- end }}
{{- include "service.nonsensitiveEnvVars" (list $global.Values.global .Values) | nindent 10 }}
{{- range $i, $container := .Values.sidecars }}
{{- with omit $container "envFrom" }}
{{- with omit $container "envFrom" "env" }}
- {{- toYaml . | nindent 10 }}
{{- include "service.configuration" $service | nindent 10}}
{{- end }}
{{- include "service.nonsensitiveEnvVars" (list $global.Values.global $service.Values $container) | nindent 10 }}
{{- end }}
initContainers:
{{- range $i, $container := .Values.initContainers }}
{{- $imageDict := fromYaml (include "initContainer.image" (dict "Chart" $global.Chart "Values" $container)) }}
{{- $container = mergeOverwrite $container $imageDict }}
{{- with omit $container "envFrom" }}
{{- with omit $container "envFrom" "env" }}
- {{- toYaml . | nindent 10 }}
{{- include "service.configuration" $service | nindent 10}}
{{- end }}
{{- include "service.nonsensitiveEnvVars" (list $global.Values.global $service.Values $container) | nindent 10 }}
{{- end }}
dnsPolicy: {{ .Values.dnsPolicy }}
restartPolicy: {{ .Values.restartPolicy }}
Expand Down
3 changes: 3 additions & 0 deletions stack/values.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Service defaults
global:
deploymentStage: ''
replicaCount: 1

# Settings for the primary container
Expand Down Expand Up @@ -50,6 +51,8 @@ global:
command:
- ps
- '-ef'

progressDeadlineSeconds: 600

resources:
limits:
Expand Down

0 comments on commit 5af70f1

Please sign in to comment.