diff --git a/README.md b/README.md index d77addaa..e77becb1 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ helm delete --namespace test my-application | deployment.fluentdConfigAnnotations | object | `nil` | Configuration details for fluentdConfigurations. Only works for specific setup, see . | | deployment.replicas | int | `nil` | Number of replicas. | | deployment.imagePullSecrets | list | `[]` | List of secrets to be used for pulling the images. | -| deployment.envFrom | object | `nil` | Mount environment variables from ConfigMap or Secret to the pod. See the README "Consuming environment variable in application chart" section for more details. | +| deployment.envFrom | object | `nil` | Mount environment variables from ConfigMap or Secret to the pod. Use `nameSuffix` for resources managed by this chart (name will be prefixed with application name), or `name` to reference an existing external ConfigMap or Secret not managed by this chart. See the README "Consuming environment variable in application chart" section for more details. | | deployment.env | object | `nil` | Environment variables to be added to the pod. See the README "Consuming environment variable in application chart" section for more details. | | deployment.volumes | object | `nil` | Volumes to be added to the pod. Key is the name of the volume. Value is the volume definition. | | deployment.volumeMounts | object | `nil` | Mount path for Volumes. Key is the name of the volume. Value is the volume mount definition. | @@ -485,6 +485,15 @@ In order to use environment variable in deployment or cronjob, you will have to **Note:** first key after `envFrom` is just used to uniquely identify different objects in `envFrom` block. Make sure to keep it unique and relevant. + To reference an **existing external ConfigMap** not managed by this chart, use `name` instead of `nameSuffix`: + + ```yaml + envFrom: + external-configmap: + type: configmap + name: my-existing-configmap + ``` + - To get environment variable value from **Secret** Suppose we have secret created from application chart @@ -525,6 +534,15 @@ In order to use environment variable in deployment or cronjob, you will have to **Note:** first key after `envFrom` is just used to uniquely identify different objects in `envFrom` block. Make sure to keep it unique and relevant. + To reference an **existing external Secret** not managed by this chart, use `name` instead of `nameSuffix`: + + ```yaml + envFrom: + external-secret: + type: secret + name: my-existing-secret + ``` + ## Configuring probes To disable liveness or readiness probe, set value of `enabled` to `false`. diff --git a/README.md.gotmpl b/README.md.gotmpl index a4657e4c..7f699b66 100644 --- a/README.md.gotmpl +++ b/README.md.gotmpl @@ -102,6 +102,15 @@ In order to use environment variable in deployment or cronjob, you will have to **Note:** first key after `envFrom` is just used to uniquely identify different objects in `envFrom` block. Make sure to keep it unique and relevant. + To reference an **existing external ConfigMap** not managed by this chart, use `name` instead of `nameSuffix`: + + ```yaml + envFrom: + external-configmap: + type: configmap + name: my-existing-configmap + ``` + - To get environment variable value from **Secret** Suppose we have secret created from application chart @@ -142,6 +151,15 @@ In order to use environment variable in deployment or cronjob, you will have to **Note:** first key after `envFrom` is just used to uniquely identify different objects in `envFrom` block. Make sure to keep it unique and relevant. + To reference an **existing external Secret** not managed by this chart, use `name` instead of `nameSuffix`: + + ```yaml + envFrom: + external-secret: + type: secret + name: my-existing-secret + ``` + ## Configuring probes To disable liveness or readiness probe, set value of `enabled` to `false`. diff --git a/application/tests/deployment_test.yaml b/application/tests/deployment_test.yaml index 290edb19..44404540 100644 --- a/application/tests/deployment_test.yaml +++ b/application/tests/deployment_test.yaml @@ -203,6 +203,34 @@ tests: path: spec.template.spec.containers[0].envFrom[0].secretRef.optional value: true + - it: configures envFrom with external secret not managed by chart + set: + deployment.envFrom: + external-secret: + type: secret + name: my-existing-secret + asserts: + - equal: + path: spec.template.spec.containers[0].envFrom[0].secretRef.name + value: my-existing-secret + - equal: + path: spec.template.spec.containers[0].envFrom[0].secretRef.optional + value: false + + - it: configures envFrom with external configmap not managed by chart + set: + deployment.envFrom: + external-configmap: + type: configmap + name: my-existing-configmap + asserts: + - equal: + path: spec.template.spec.containers[0].envFrom[0].configMapRef.name + value: my-existing-configmap + - equal: + path: spec.template.spec.containers[0].envFrom[0].configMapRef.optional + value: false + - it: includes application.stakater.com/workload-class label in pod template for service selector set: deployment: diff --git a/application/values-test.yaml b/application/values-test.yaml index 268300e3..fa8b3fdf 100644 --- a/application/values-test.yaml +++ b/application/values-test.yaml @@ -87,6 +87,12 @@ deployment: type: secret nameSuffix: nonexisting optional: true + external-secret: + type: secret + name: my-existing-secret + external-configmap: + type: configmap + name: my-existing-configmap # Environment variables to be passed to the app container env: diff --git a/application/values.yaml b/application/values.yaml index 2ec59d08..69078069 100644 --- a/application/values.yaml +++ b/application/values.yaml @@ -191,6 +191,8 @@ deployment: imagePullSecrets: [] # - name: docker-pull # -- (object) Mount environment variables from ConfigMap or Secret to the pod. See the README "Consuming environment variable in application chart" section for more details. + # Use `nameSuffix` for resources managed by this chart (name will be prefixed with application name), + # or `name` to reference an existing external ConfigMap or Secret not managed by this chart. # @section -- Deployment Parameters envFrom: # production-cm: @@ -204,6 +206,12 @@ deployment: # type: secret # nameSuffix: extra # optional: true + # external-secret: + # type: secret + # name: my-existing-secret + # external-configmap: + # type: configmap + # name: my-existing-configmap # -- (object) Environment variables to be added to the pod. See the README "Consuming environment variable in application chart" section for more details. # @section -- Deployment Parameters env: