Skip to content

Commit 38371d4

Browse files
authored
Added example to use configMapGenerator from .env file
1 parent 3316bae commit 38371d4

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

content/en/docs/tasks/manage-kubernetes-objects/kustomization.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,41 @@ metadata:
8686
name: example-configmap-1-8mbdf7882g
8787
```
8888
89+
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:
90+
91+
```shell
92+
# Create a .env file
93+
cat <<EOF >.env
94+
FOO=Bar
95+
EOF
96+
97+
cat <<EOF >./kustomization.yaml
98+
configMapGenerator:
99+
- name: example-configmap-1
100+
envs:
101+
- .env
102+
EOF
103+
```
104+
105+
The generated ConfigMap can be examined with the following command:
106+
107+
```shell
108+
kubectl kustomize ./
109+
```
110+
111+
The generated ConfigMap is:
112+
113+
```yaml
114+
apiVersion: v1
115+
data:
116+
FOO=Bar
117+
kind: ConfigMap
118+
metadata:
119+
name: example-configmap-1-8mbdf7882g
120+
```
121+
122+
**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.
123+
89124
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:
90125

91126
```shell

0 commit comments

Comments
 (0)