You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/en/docs/tasks/manage-kubernetes-objects/kustomization.md
+35Lines changed: 35 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -86,6 +86,41 @@ metadata:
86
86
name: example-configmap-1-8mbdf7882g
87
87
```
88
88
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
+
89
124
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:
0 commit comments