Skip to main content
Kubernetes coreLesson 10 of 13

How Storage Gets Attached (PVC·PV)

We request 10Gi of storage for a database pod. Let's follow how one request turns into a real disk attached to the pod, and why the data survives when the pod goes away.

PVC statusPending
PVNone
Pod statusNone
DataNone
node-2OperatorRequests a PVCPVC10Gi · RWOPendingStorageClassfast · specProvisionerCSI controllerStorageReal diskPVActual 10GikubeletCSI nodedbPodcreate PVC
RequestResponse / reportWatchAppears in a later step

What you will learn

  • How PVC, PV, and StorageClass relate
  • How a provisioner creates a disk
  • Who does attach and who does mount
  • Why data survives when the pod is deleted
  • Common reasons a PVC stays Pending

Symptoms by the stage that stopped​

Stage that stoppedWhat kubectl get showsWhere to look
3. Create diskPVC stays PendingPVC events — StorageClass name typo, provisioner not installed, out of capacity, unsupported access mode
6. Attach to nodePod stays in ContainerCreatingFailedAttachVolume in pod events — often the volume is still attached to another node
6. MountPod stays in ContainerCreatingFailedMount in pod events — permissions, file system errors, NFS server unreachable

Try it yourself​

kubectl get storageclass # PROVISIONER and VOLUMEBINDINGMODE
kubectl get pvc # Pending or Bound
kubectl describe pvc <pvc> # Why it stays Pending (Events)
kubectl get pv # RECLAIM POLICY before deleting a PVC
kubectl get volumeattachments # Which node a volume is attached to
kubectl describe pod <pod> # FailedAttachVolume or FailedMount

Check yourself

  1. A new PVC has stayed Pending for a long time with no error, and its StorageClass does not use WaitForFirstConsumer. Where should you look first?
  2. The db pod is deleted, and a new pod uses the same PVC. What happens to the data?
  3. A db pod moved to another node stays in ContainerCreating with FailedAttachVolume. Its volume is RWO. What is a likely cause?

Further reading: Persistent Volumes · Storage Classes