Using ConfigMap via volume

Similar to previous examples in the Secrets subsection, we mount a volume with configmap syntax and add volumeMounts inside a container template. The command in centos will loop to cat ${MOUNTPOINT}/$CONFIG_FILENAME:

cat 3-2-3_pod_vol_configmap.yaml
apiVersion: v1
kind: Pod
metadata:
name: configmap-vol
spec:
containers:
- name: configmap
image: centos
command: ["/bin/sh", "-c", "while : ;do cat /src/app/config/database.properties; sleep 10; done"]
volumeMounts:
- name: config-volume
mountPath: /src/app/config
volumes:
- name: config-volume
configMap:
name: example
// create configmap
# kubectl create -f 3-2-3_pod_vol_configmap.yaml
pod "configmap-vol" created
// check out the logs
# kubectl logs -f configmap-vol
endpoint=k8s.us-east-1.rds.amazonaws.com
port=1521

We then could use this method to inject our non-sensitive configuration into the pod.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset