Skip to content

Storage and CSI

Draft: not yet run against a live cluster. Treat output as representative and check it on yours.

Storage failures are slow and quiet. A pod sits in ContainerCreating for six minutes, then reports a timeout that names a volume ID nobody recognises. Knowing which component owns each step turns that into a two-minute diagnosis.

  1. Provision. When a PVC is created, the CSI external provisioner sees it and calls the storage backend to create a disk, then creates a PV and binds it. If the StorageClass uses volumeBindingMode: WaitForFirstConsumer, this waits until a pod using the claim is scheduled, so the disk is created in the right zone. Until then the PVC is Pending, and that’s normal.

  2. Attach. Once the pod is scheduled, the attach/detach controller creates a VolumeAttachment, and the CSI driver’s controller plugin attaches the disk to that node. Network filesystems (NFS and similar) skip this step.

  3. Mount. The kubelet on the node calls the CSI node plugin to stage the device (format if needed, mount once per node) and then publish it into the pod’s directory.

  4. On deletion, reclaimPolicy decides the data’s fate. Delete (the default for dynamic provisioning) deletes the disk when the PVC is deleted. Retain keeps it for manual recovery.

Access modes describe how the volume can be mounted, not what the app does with it: ReadWriteOnce (one node at a time), ReadOnlyMany, ReadWriteMany, and ReadWriteOncePod (one pod at a time).

kind ships a default StorageClass backed by node-local storage, enough to watch the binding flow:

Terminal window
kubectl get storageclass
pvc.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: data
spec:
accessModes: [ReadWriteOnce]
resources:
requests: { storage: 1Gi }
---
apiVersion: v1
kind: Pod
metadata:
name: writer
spec:
containers:
- name: app
image: busybox:1.36
command: ['sh', '-c', 'date >> /data/log; sleep 3600']
volumeMounts: [{ name: data, mountPath: /data }]
volumes:
- name: data
persistentVolumeClaim: { claimName: data }
Terminal window
kubectl apply -f pvc.yaml
kubectl get pvc data -w # Pending until the pod schedules, then Bound
kubectl get pv
A PVC is Pending and its event says waiting for first consumer. Is something broken?

No. With WaitForFirstConsumer, binding waits until a pod using the claim is scheduled.

Why does a rolling update of a Deployment with one ReadWriteOnce volume often get stuck?

The new pod starts before the old one stops, possibly on another node, and an RWO disk can only be attached to one node at a time.

What happens to the data when you delete a PVC whose PV has reclaimPolicy Delete?

The underlying disk is deleted along with the PV. The data is gone.

Maps to: CKA: Storage. Check the current exam curriculum, since domain names change between revisions.