liveBook · Manning

Access mode

As explained in Kubernetes in Action, Second Edition

An access mode is a PersistentVolume and PersistentVolumeClaim specification describing how a volume may be mounted by nodes or pods for reading and writing.

An access mode describes how a PersistentVolume may be mounted for reading and writing. An application requests one in a PersistentVolumeClaim (PVC), alongside a minimum storage size. The choice matters when more than one pod needs the same data: some modes limit use to one pod, while others allow sharing across nodes. section 10.2.1 section 10.6

Listing 10.1 A minimal PVC definition using the default storage class
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: quiz-data
spec:     #1
  resources:             #2
    requests:            #2
      storage: 1Gi       #2
  accessModes:             #3
  - ReadWriteOncePod       #3

This minimal claim requests 1Gi of storage with `ReadWriteOncePod` access. It relies on the cluster’s default StorageClass. section 10.2.1

Choose the mode that matches who needs to use the volume:

One pod or one node?

If a second pod uses a `ReadWriteOncePod` claim while the first is running, the second remains `Pending`. With `ReadWriteOnce`, several pods on the same node can read and write the volume, but pods scheduled on another node can remain in `ContainerCreating` because the volume cannot attach there. Check pod placement with `kubectl get pods -o wide` and attachment events with `kubectl describe`. section 10.2.4

A claim’s access mode is part of its storage requirements. With static provisioning, Kubernetes looks for an available PersistentVolume that meets those requirements and binds it to the claim. With dynamic provisioning, a volume is created for the claim using its requirements and StorageClass. Once a pod uses the claim, the volume is attached to a node and mounted into the pod’s containers. Access mode is distinct from volume mode: volume mode determines whether the container receives a filesystem or a raw block device. section 10.1.2 section 10.6 section 10.2.1

How Kubernetes in Action, Second Edition covers it

How deep it goes
Distinguishes four modes by pod, node, and read/write access, then demonstrates scheduling and attachment failures; does not detail storage-driver internals.
Examples
Uses a 1Gi claim, competing quiz pods, and same-node versus different-node pods to show the modes’ effects.
What you can do after
Apply it via PersistentVolumeClaim manifests to request a sharing pattern and diagnose pod attachment problems with kubectl.
How it connects
Connects PersistentVolumeClaims and PersistentVolumes to pod scheduling, StorageClasses, and static or dynamic provisioning.

Also explained in

Compare how 3 books explain access mode →

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.