Skip to content

Commit

Permalink
Adds ability to use secretKeyRef in env spec (#264)
Browse files Browse the repository at this point in the history
* Add secretkeyref to env helper

* Add example values; bump chart version
  • Loading branch information
asiegman authored Dec 19, 2020
1 parent 39e5010 commit 9617ae3
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
4 changes: 2 additions & 2 deletions incubator/monochart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
apiVersion: v1
description: A declarative helm chart for deploying common types of services on Kubernetes
name: monochart
version: 0.24.0
appVersion: 0.24.0
version: 0.25.0
appVersion: 0.25.0
home: https://github.com/cloudposse/charts/tree/master/incubator/monochart
icon: https://raw.githubusercontent.com/cloudposse/charts/master/incubator/monochart/logo.png
maintainers:
Expand Down
12 changes: 12 additions & 0 deletions incubator/monochart/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@ env:
fieldPath: {{ $value }}
{{- end }}
{{- end }}
{{/*
https://kubernetes.io/docs/concepts/configuration/secret/#using-secrets-as-environment-variables
*/}}
{{- with $root.Values.envFromSecretKeyRef }}
{{- range $data := . }}
- name: {{ $data.name }}
valueFrom:
secretKeyRef:
name: {{ $data.secret }}
key: {{ $data.key }}
{{- end }}
{{- end }}
{{- end -}}


Expand Down
7 changes: 7 additions & 0 deletions incubator/monochart/values.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ envFromFieldRefFieldPath:
ENV_1: path-1
ENV_2: path-2

# ENV variables from secretkeyref
# https://kubernetes.io/docs/concepts/configuration/secret/#using-secrets-as-environment-variables
envFromSecretKeyRef:
- name: MY_ENV_VARIABLE
secret: kubernetes-secret-name
key: key-name-in-secret

deployment:
enabled: true
## Pods replace strategy
Expand Down
7 changes: 7 additions & 0 deletions incubator/monochart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ env: {}
# ENV_1: path-1
# ENV_2: path-2

# ENV variables from secretkeyref
# https://kubernetes.io/docs/concepts/configuration/secret/#using-secrets-as-environment-variables
# envFromSecretKeyRef:
# - name: MY_ENV_VARIABLE
# secret: kubernetes-secret-name
# key: key-name-in-secret

deployment:
enabled: false
## Pods replace strategy
Expand Down

0 comments on commit 9617ae3

Please sign in to comment.