Quiz: Kubernetes Storage¶
4 questions
L0 (1 questions)¶
1. What is the relationship between a PersistentVolume (PV), PersistentVolumeClaim (PVC), and StorageClass in Kubernetes?
Show answer
A PV is a cluster-level storage resource (the 'disk'). A PVC is a namespace-scoped request for storage (the 'claim'). A StorageClass defines how storage is dynamically provisioned. Pods reference PVCs, Kubernetes binds PVCs to matching PVs. With dynamic provisioning, creating a PVC with a StorageClass automatically creates the PV.L1 (1 questions)¶
1. What are the three access modes for PersistentVolumes and when would you use each?
Show answer
ReadWriteOnce (RWO): mounted read-write by a single node — use for databases. ReadOnlyMany (ROX): mounted read-only by many nodes — use for shared config or static assets. ReadWriteMany (RWX): mounted read-write by many nodes — use for shared file storage. Most cloud block storage only supports RWO; RWX requires NFS or a distributed filesystem. *Common mistake:* RWO means one node, not one pod. Multiple pods on the same node can share an RWO volume.L2 (1 questions)¶
1. A PVC is stuck in Pending state. What are the possible causes and how do you diagnose?
Show answer
Causes: (1) No StorageClass matches — check PVC's storageClassName vs available StorageClasses. (2) No PV matches (static provisioning) — check capacity, access mode, labels. (3) Provisioner is failing — check StorageClass provisioner and its controller pod logs. (4) Quota exceeded — check ResourceQuota in the namespace. Run kubectl describe pvc to see Events for the specific failure reason.L3 (1 questions)¶
1. You need to migrate a StatefulSet's data from one StorageClass to another (e.g., HDD to SSD) with minimal downtime. How?
Show answer
1. Scale StatefulSet to0.
2. For each PVC: create a temporary pod that mounts both old PVC and a new PVC (on the target StorageClass), then cp -a the data.
3. Delete old PVCs.
4. Create new PVCs with the original names bound to the new PVs (or let dynamic provisioning create them).
5. Scale StatefulSet back up. Alternative: use a tool like velero for backup/restore. Test the procedure in staging first.