Mounting Secrets and ConfigMap in the same volume

Projected volume is a way to group multiple volume sources into the same mount point. Currently, it supports Secrets, ConfigMap, and downwardAPI.

The following is an example of how we group the examples of Secrets and ConfigMaps that we used in this chapter:

// using projected volume
# cat 2-7-5_projected_volume.yaml
apiVersion: v1
kind: Pod
metadata:
name: projected-volume-example
spec:
containers:
- name: container-tes
image: ubuntu
command: ["/bin/sh", "-c", "while : ;do cat /projected-volume/configmap && cat /projected-volume/token; sleep 10; done"]
volumeMounts:
- name: projected-volume
mountPath: "/projected-volume"
volumes:
- name: projected-volume
projected:
sources:
- secret:
name: access-token
items:
- key: 2-7-1_access-token
path: token
- configMap:
name: config-example
items:
- key: app.properties
path: configmap

// create projected volume
# kubectl create -f 2-7-5_projected_volume.yaml
pod "projected-volume-example" created

Let's check stdout to see if it works properly:

# kubectl logs -f projected-volume-example
name=kubernetes-cookbook
port=443
9S!g0U61699r
..................Content has been hidden....................

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