A Kubernetes volume is a directory that containers in the same Pod can access. Its creation, backing medium, and contents depend on the volume type. Kubernetes includes built-in types, while storage drivers can add others. section 9.1 section 9.1.1
Choose the volume type according to how long the data must survive and who needs to access it:
- emptyDir provides initially empty, ephemeral node storage. Multiple containers in one Pod can share it, and its contents survive container restarts but disappear when the Pod is deleted, moved, or loses its node. section 9.1.1
- ConfigMap can present manifest-defined configuration files to an application as files on disk. section 9.1.1
- Cloud provider disks provide persistent storage for workloads such as databases, but the disk must be available in the required location. section 9.1.1
Listing 9.1 Chapter09/9.1.1_Volume/emptydir_pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: emptydir-pod
labels:
pod: timeserver-pod
spec:
containers:
- name: timeserver-container
image: docker.io/wdenniss/timeserver:5
volumeMounts:
- name: cache-volume #1
mountPath: /app/cache/ #1
volumes:
- name: cache-volume #2
emptyDir: {} #2
Mounts an emptyDir volume at /app/cache/ so the container can use node-backed scratch space. section 9.1.1
Database storage
A MariaDB Pod mounts a cloud-provider disk at /var/lib/mysql and selects the disk’s zone. If the named disk does not exist there, Kubernetes reports a FailedAttachVolume event. section 9.1.1







