Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Environment variables from ConfigMap #866

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,16 @@ Inject extra environment populated by secrets, if populated
{{- end -}}
{{- end -}}

{{- define "vault.extraEnvironmentVarsFromConfigMap" -}}
{{- if .extraEnvironmentVarsFromConfigMap -}}
envFrom:
{{- range .extraEnvironmentVarsFromConfigMap }}
- configMapRef:
name: {{ . }}
{{- end -}}
{{- end -}}
{{- end -}}

{{/* Scheme for health check and local endpoint */}}
{{- define "vault.scheme" -}}
{{- if .Values.global.tlsDisable -}}
Expand Down
1 change: 1 addition & 0 deletions templates/server-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ spec:
{{ template "vault.envs" . }}
{{- include "vault.extraEnvironmentVars" .Values.server | nindent 12 }}
{{- include "vault.extraSecretEnvironmentVars" .Values.server | nindent 12 }}
{{- include "vault.extraEnvironmentVarsFromConfigMap" .Values.server | nindent 10 }}
volumeMounts:
{{ template "vault.mounts" . }}
- name: home
Expand Down
18 changes: 18 additions & 0 deletions test/unit/server-statefulset.bats
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,24 @@ load _helpers
[ "${name}" = "foobar" ]
}

@test "server/standalone-StatefulSet: set extraEnvironmentVarsFromConfigMap" {
cd `chart_dir`
local object=$(helm template \
--show-only templates/server-statefulset.yaml \
--set 'server.standalone.enabled=true' \
--set 'server.extraEnvironmentVarsFromConfigMap={foo,bar}' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.containers[0].envFrom' | tee /dev/stderr)

local name=$(echo $object |
yq -r '.[0] .configMapRef.name' | tee /dev/stderr)
[ "${name}" = "foo" ]

local name=$(echo $object |
yq -r '.[1] .configMapRef.name' | tee /dev/stderr)
[ "${name}" = "bar" ]
}

#--------------------------------------------------------------------
# storage class

Expand Down
3 changes: 3 additions & 0 deletions values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,9 @@
"extraSecretEnvironmentVars": {
"type": "array"
},
"extraEnvironmentVarsFromConfigMap": {
"type": "array"
},
"extraVolumes": {
"type": "array"
},
Expand Down
6 changes: 6 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,12 @@ server:
# secretName: vault
# secretKey: AWS_SECRET_ACCESS_KEY

# extraEnvironmentVarsFromConfigMap is a list of ConfigMap's name whose data as environment variables
# to set with the stateful set.
extraEnvironmentVarsFromConfigMap: []
# - my-configmap
# - my-configmap2

# Deprecated: please use 'volumes' instead.
# extraVolumes is a list of extra volumes to mount. These will be exposed
# to Vault in the path `/vault/userconfig/<name>/`. The value below is
Expand Down