A volume mount makes volume-backed data available at a path inside a container. In Kubernetes, the container’s volumeMounts entry names the volume and sets its mountPath. section 7.4
Use volume mounts to expose different kinds of data:
- Mount an emptyDir volume for temporary storage that lasts for the lifetime of the Pod. section 7.4
- Mount ConfigMap data into a container when applications need configuration files. section 4.2.4
- Mount Secret data into a directory, or provide it through environment variables. section 4.2.5
Mount an emptyDir volume at /var/log
Define the same name under the container’s volumeMounts and the Pod’s volumes: volumeMounts: [{mountPath: /var/log, name: logvol}] and volumes: [{name: logvol, emptyDir: {}}]. Create it with kubectl create -f log-collector.yaml, then verify the Running Pod with kubectl get po and the EmptyDir mount with kubectl describe po log-collector. section 7.4
1 apiVersion: v1
2 kind: Pod
3 metadata:
4 creationTimestamp: null
5 labels:
6 run: log-collector
7 name: log-collector
8 spec:
9 containers:
10 - command:
11 - sleep
12 - "3600"
13 image: busybox
14 name: log-collector
15 resources: {}
16 volumeMounts:
17 - mountPath: /var/log
18 name: logvol
19 dnsPolicy: ClusterFirst
20 restartPolicy: Always
21 volumes:
22 - name: logvol
23 emptyDir: {}
Inspect the complete Pod manifest showing the matching volume name, mountPath, and emptyDir definition. section 7.4

