liveBook · Manning

Volume

As explained in Kubernetes for Developers

A Kubernetes volume is a directory-backed storage abstraction accessible to containers in a Pod, with its medium and contents determined by its volume type.

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

How Kubernetes for Developers covers it

How deep it goes
Explains directory semantics, lifecycle differences, mounts, and attachment failure, while deferring higher-level StatefulSet design.
Examples
Uses an emptyDir cache, a MariaDB cloud disk, a zone-specific disk, and a FailedAttachVolume event.
What you can do after
Apply volumes via Kubernetes Pod manifests and diagnose cloud-disk attachment failures from events.
How it connects
Connects volumes with Pods, containers, ConfigMaps, persistent storage, storage drivers, and StatefulSets.

Also explained in

Compare how 8 books explain volume →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Kubernetes for Developers. The section links point to the parts of the book it draws on.