Update example to configure pods
parent
bdadfbcf45
commit
6d0f8be9bc
|
@ -111,46 +111,7 @@ technique also lets you access a ConfigMap in a different namespace.
|
||||||
|
|
||||||
Here's an example Pod that uses values from `game-demo` to configure a Pod:
|
Here's an example Pod that uses values from `game-demo` to configure a Pod:
|
||||||
|
|
||||||
```yaml
|
{{< codenew file="configmap/configure-pod.yaml" >}}
|
||||||
apiVersion: v1
|
|
||||||
kind: Pod
|
|
||||||
metadata:
|
|
||||||
name: configmap-demo-pod
|
|
||||||
spec:
|
|
||||||
containers:
|
|
||||||
- name: demo
|
|
||||||
image: alpine
|
|
||||||
command: ["sleep", "3600"]
|
|
||||||
env:
|
|
||||||
# Define the environment variable
|
|
||||||
- name: PLAYER_INITIAL_LIVES # Notice that the case is different here
|
|
||||||
# from the key name in the ConfigMap.
|
|
||||||
valueFrom:
|
|
||||||
configMapKeyRef:
|
|
||||||
name: game-demo # The ConfigMap this value comes from.
|
|
||||||
key: player_initial_lives # The key to fetch.
|
|
||||||
- name: UI_PROPERTIES_FILE_NAME
|
|
||||||
valueFrom:
|
|
||||||
configMapKeyRef:
|
|
||||||
name: game-demo
|
|
||||||
key: ui_properties_file_name
|
|
||||||
volumeMounts:
|
|
||||||
- name: config
|
|
||||||
mountPath: "/config"
|
|
||||||
readOnly: true
|
|
||||||
volumes:
|
|
||||||
# You set volumes at the Pod level, then mount them into containers inside that Pod
|
|
||||||
- name: config
|
|
||||||
configMap:
|
|
||||||
# Provide the name of the ConfigMap you want to mount.
|
|
||||||
name: game-demo
|
|
||||||
# An array of keys from the ConfigMap to create as files
|
|
||||||
items:
|
|
||||||
- key: "game.properties"
|
|
||||||
path: "game.properties"
|
|
||||||
- key: "user-interface.properties"
|
|
||||||
path: "user-interface.properties"
|
|
||||||
```
|
|
||||||
|
|
||||||
A ConfigMap doesn't differentiate between single line property values and
|
A ConfigMap doesn't differentiate between single line property values and
|
||||||
multi-line file-like values.
|
multi-line file-like values.
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Pod
|
||||||
|
metadata:
|
||||||
|
name: configmap-demo-pod
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: demo
|
||||||
|
image: alpine
|
||||||
|
command: ["sleep", "3600"]
|
||||||
|
env:
|
||||||
|
# Define the environment variable
|
||||||
|
- name: PLAYER_INITIAL_LIVES # Notice that the case is different here
|
||||||
|
# from the key name in the ConfigMap.
|
||||||
|
valueFrom:
|
||||||
|
configMapKeyRef:
|
||||||
|
name: game-demo # The ConfigMap this value comes from.
|
||||||
|
key: player_initial_lives # The key to fetch.
|
||||||
|
- name: UI_PROPERTIES_FILE_NAME
|
||||||
|
valueFrom:
|
||||||
|
configMapKeyRef:
|
||||||
|
name: game-demo
|
||||||
|
key: ui_properties_file_name
|
||||||
|
volumeMounts:
|
||||||
|
- name: config
|
||||||
|
mountPath: "/config"
|
||||||
|
readOnly: true
|
||||||
|
volumes:
|
||||||
|
# You set volumes at the Pod level, then mount them into containers inside that Pod
|
||||||
|
- name: config
|
||||||
|
configMap:
|
||||||
|
# Provide the name of the ConfigMap you want to mount.
|
||||||
|
name: game-demo
|
||||||
|
# An array of keys from the ConfigMap to create as files
|
||||||
|
items:
|
||||||
|
- key: "game.properties"
|
||||||
|
path: "game.properties"
|
||||||
|
- key: "user-interface.properties"
|
||||||
|
path: "user-interface.properties"
|
||||||
|
|
Loading…
Reference in New Issue