From 38371d43e6563d7b09c099979c0ecfc98f257ed4 Mon Sep 17 00:00:00 2001 From: Rojo Date: Thu, 6 May 2021 18:51:40 +0200 Subject: [PATCH 1/2] Added example to use configMapGenerator from .env file --- .../kustomization.md | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/content/en/docs/tasks/manage-kubernetes-objects/kustomization.md b/content/en/docs/tasks/manage-kubernetes-objects/kustomization.md index a41bab6736..2ac0143934 100644 --- a/content/en/docs/tasks/manage-kubernetes-objects/kustomization.md +++ b/content/en/docs/tasks/manage-kubernetes-objects/kustomization.md @@ -86,6 +86,41 @@ metadata: name: example-configmap-1-8mbdf7882g ``` +To generate a ConfigMap from an env file, add an entry to the `envs` list in `configMapGenerator`. Here is an example of generating a ConfigMap with a data item from a `.env` file: + +```shell +# Create a .env file +cat <.env +FOO=Bar +EOF + +cat <./kustomization.yaml +configMapGenerator: +- name: example-configmap-1 + envs: + - .env +EOF +``` + +The generated ConfigMap can be examined with the following command: + +```shell +kubectl kustomize ./ +``` + +The generated ConfigMap is: + +```yaml +apiVersion: v1 +data: + FOO=Bar +kind: ConfigMap +metadata: + name: example-configmap-1-8mbdf7882g +``` + +**Note:** They variables are added as top level keys in the ConfigMap, instead of nested within the name of the file, like the previous example does. + ConfigMaps can also be generated from literal key-value pairs. To generate a ConfigMap from a literal key-value pair, add an entry to the `literals` list in configMapGenerator. Here is an example of generating a ConfigMap with a data item from a key-value pair: ```shell From 7a2baf6865704b6007ee7dc102519a5dcd16113f Mon Sep 17 00:00:00 2001 From: Rojo Date: Thu, 6 May 2021 21:12:33 +0200 Subject: [PATCH 2/2] Update content/en/docs/tasks/manage-kubernetes-objects/kustomization.md Co-authored-by: Tim Bannister --- .../en/docs/tasks/manage-kubernetes-objects/kustomization.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/content/en/docs/tasks/manage-kubernetes-objects/kustomization.md b/content/en/docs/tasks/manage-kubernetes-objects/kustomization.md index 2ac0143934..27f3762988 100644 --- a/content/en/docs/tasks/manage-kubernetes-objects/kustomization.md +++ b/content/en/docs/tasks/manage-kubernetes-objects/kustomization.md @@ -119,7 +119,9 @@ metadata: name: example-configmap-1-8mbdf7882g ``` -**Note:** They variables are added as top level keys in the ConfigMap, instead of nested within the name of the file, like the previous example does. +{{< note >}} +Each variable in the `.env` file becomes a separate key in the ConfigMap that you generate. This is different from the previous example which embeds a file named `.properties` (and all its entries) as the value for a single key. +{{< /note >}} ConfigMaps can also be generated from literal key-value pairs. To generate a ConfigMap from a literal key-value pair, add an entry to the `literals` list in configMapGenerator. Here is an example of generating a ConfigMap with a data item from a key-value pair: @@ -1010,4 +1012,3 @@ deployment.apps "dev-my-nginx" deleted * [Kubectl Command Reference](/docs/reference/generated/kubectl/kubectl-commands/) * [Kubernetes API Reference](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/) -