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/zh/docs/tasks/manage-kubernetes-objects/kustomization.md
+18-4Lines changed: 18 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -133,15 +133,28 @@ metadata:
133
133
```
134
134
135
135
<!--
136
-
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:
136
+
To generate a ConfigMap from an env file, add an entry to the `envs` list in `configMapGenerator`. This can also be used to set values from local environment variables by omitting the `=` and the value.
It's recommended to use the local environment variable population functionality sparingly - an overlay with a patch is often more maintainable. Setting values from the environment may be useful when they cannot easily be predicted, such as a git SHA.
143
+
-->
144
+
建议谨慎使用本地环境变量填充功能 —— 用补丁覆盖通常更易于维护。
145
+
当无法轻松预测变量的值时,从环境中设置值可能很有用,例如 git SHA。
146
+
147
+
<!--
148
+
Here is an example of generating a ConfigMap with a data item from a `.env` file:
149
+
-->
139
150
下面是一个用来自 `.env` 文件的数据生成 ConfigMap 的例子:
140
151
141
152
```shell
142
153
# 创建一个 .env 文件
154
+
# BAZ 将使用本地环境变量 $BAZ 的取值填充
143
155
cat <<EOF >.env
144
156
FOO=Bar
157
+
BAZ
145
158
EOF
146
159
147
160
cat <<EOF >./kustomization.yaml
@@ -158,7 +171,7 @@ The generated ConfigMap can be examined with the following command:
158
171
可以使用以下命令检查生成的 ConfigMap:
159
172
160
173
```shell
161
-
kubectl kustomize ./
174
+
BAZ=Qux kubectl kustomize ./
162
175
```
163
176
164
177
<!--
@@ -169,10 +182,11 @@ The generated ConfigMap is:
169
182
```yaml
170
183
apiVersion: v1
171
184
data:
185
+
BAZ: Qux
172
186
FOO: Bar
173
187
kind: ConfigMap
174
188
metadata:
175
-
name: example-configmap-1-42cfbf598f
189
+
name: example-configmap-1-892ghb99c8
176
190
```
177
191
178
192
<!--
@@ -398,7 +412,7 @@ type: Opaque
398
412
```
399
413
400
414
<!--
401
-
Like ConfigMaps, generated Secrets can be used in Deployments by refering to the name of the secretGenerator:
415
+
Like ConfigMaps, generated Secrets can be used in Deployments by referring to the name of the secretGenerator:
0 commit comments