ConfigMap Volume
We can mount ConfigMap as volume as shown below.
apiVersion: v1
kind: Pod
metadata:
name: configmap-volume
namespace: learning
spec:
containers:
- image: nginx
name: nginx
volumeMounts:
- name: configmap
mountPath: /config
volumes:
- name: configmap
configMap:
name: credentials
items:
- key: USERNAME
path: username.txt
- key: PASSWORD
path: password.txt
We must ensure the ConfigMap credentials
should be present.
apiVersion: v1
kind: ConfigMap
metadata:
name: credentials
namespace: learning
data:
USERNAME: "nitinsharmacs"
PASSWORD: "password"
This will mount files username.txt
and password.txt
with their values as specified in ConfigMap. These mounts are ReadOnly
.