liveBook · Manning

Volume binding mode

As explained in Kubernetes in Action, Second Edition

A volume binding mode is a StorageClass setting that determines when a PersistentVolume is bound to a PersistentVolumeClaim.

A volume binding mode is a StorageClass setting that controls when Kubernetes provisions and binds a PersistentVolume to a PersistentVolumeClaim. It determines whether the claim is handled immediately or after a pod begins using it. section 10.2.5 section 10.2.1

The supported modes differ in when the consumer’s location is known:

  • Immediate provisions and binds the PersistentVolume as soon as the PersistentVolumeClaim is created. Because no consuming pod is known yet, this suits volumes accessible from any cluster node. section 10.2.5
  • WaitForFirstConsumer delays provisioning and binding until the first pod referencing the claim is created. This lets scheduling account for storage that is limited to particular nodes. section 10.2.5 section 10.3.1
Table 10.4 Supported volume binding modes
Volume binding mode
Description
Immediate
The provision and binding of the PersistentVolume takes place immediately after the PersistentVolumeClaim is created. Because the consumer of the claim is unknown at this point, this mode is only applicable to volumes that can be accessed from any cluster node.
WaitForFirstConsumer
The PersistentVolume is provisioned and bound to the PersistentVolumeClaim when the first pod referencing this claim is created. Many StorageClasses now use this mode.

Compare Immediate and WaitForFirstConsumer when choosing a StorageClass for a claim. section 10.2.5

Binding a local volume after pod creation

A local StorageClass can use `WaitForFirstConsumer` with the `kubernetes.io/no-provisioner` provisioner. Creating a claim such as `quiz-data-local` leaves it unbound initially. Creating a pod that references the claim lets Kubernetes bind the claim to the local PersistentVolume and schedule the pod on the node that can access the volume. section 10.3.1 section 10.3.2

How Kubernetes in Action, Second Edition covers it

How deep it goes
Defines both modes and follows delayed binding through local-volume provisioning, pod creation, binding, and scheduling.
Examples
Uses GKE StorageClasses, a local StorageClass manifest, and a local claim whose binding begins when its pod is created.
What it assumes
Assumes PersistentVolumeClaims and pods, while establishing how StorageClasses, provisioners, and local-volume constraints interact.
What you can do after
Configure StorageClasses and diagnose Pending claims with kubectl by relating binding timing to pod creation and node access.
How it connects
Connects StorageClass, PersistentVolumeClaim, PersistentVolume, provisioners, pod scheduling, and node affinity.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Kubernetes in Action, Second Edition. The section links point to the parts of the book it draws on.