Skip to content

Commit

Permalink
Sync /configuration/configmap.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jzhupup committed Nov 1, 2022
1 parent ff852e3 commit 9ebed5a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 39 deletions.
40 changes: 1 addition & 39 deletions content/zh-cn/docs/concepts/configuration/configmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,45 +189,7 @@ Here's an example Pod that uses values from `game-demo` to configure a Pod:

下面是一个 Pod 的示例,它通过使用 `game-demo` 中的值来配置一个 Pod:

```yaml
apiVersion: v1
kind: Pod
metadata:
name: configmap-demo-pod
spec:
containers:
- name: demo
image: alpine
command: ["sleep", "3600"]
env:
# 定义环境变量
- name: PLAYER_INITIAL_LIVES # 请注意这里和 ConfigMap 中的键名是不一样的
valueFrom:
configMapKeyRef:
name: game-demo # 这个值来自 ConfigMap
key: player_initial_lives # 需要取值的键
- name: UI_PROPERTIES_FILE_NAME
valueFrom:
configMapKeyRef:
name: game-demo
key: ui_properties_file_name
volumeMounts:
- name: config
mountPath: "/config"
readOnly: true
volumes:
# 你可以在 Pod 级别设置卷,然后将其挂载到 Pod 内的容器中
- name: config
configMap:
# 提供你想要挂载的 ConfigMap 的名字
name: game-demo
# 来自 ConfigMap 的一组键,将被创建为文件
items:
- key: "game.properties"
path: "game.properties"
- key: "user-interface.properties"
path: "user-interface.properties"
```
{{< codenew file="configmap/configure-pod.yaml" >}}

<!--
A ConfigMap doesn't differentiate between single line property values and
Expand Down
38 changes: 38 additions & 0 deletions content/zh-cn/examples/configmap/configure-pod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
apiVersion: v1
kind: Pod
metadata:
name: configmap-demo-pod
spec:
containers:
- name: demo
image: alpine
command: ["sleep", "3600"]
env:
# 定义环境变量
- name: PLAYER_INITIAL_LIVES # 请注意这里和 ConfigMap 中的键名是不一样的
valueFrom:
configMapKeyRef:
name: game-demo # 这个值来自 ConfigMap
key: player_initial_lives # 需要取值的键
- name: UI_PROPERTIES_FILE_NAME
valueFrom:
configMapKeyRef:
name: game-demo
key: ui_properties_file_name
volumeMounts:
- name: config
mountPath: "/config"
readOnly: true
volumes:
# 你可以在 Pod 级别设置卷,然后将其挂载到 Pod 内的容器中
- name: config
configMap:
# 提供你想要挂载的 ConfigMap 的名字
name: game-demo
# 来自 ConfigMap 的一组键,将被创建为文件
items:
- key: "game.properties"
path: "game.properties"
- key: "user-interface.properties"
path: "user-interface.properties"

0 comments on commit 9ebed5a

Please sign in to comment.