-
Notifications
You must be signed in to change notification settings - Fork 14.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
39 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
|