Interactive Lab ยท CKA Topic

PV & PVC DEEP DIVE

$ kubectl apply -f your-knowledge.yaml
๐Ÿš€
POD
Your workload.
Needs storage.
โ†
mounts via
๐Ÿ“‹
PVC
PersistentVolumeClaim
A storage request.
โ†
binds to
๐Ÿ’พ
PV
PersistentVolume
The actual disk.
๐Ÿ’พ Step 1 Define a PersistentVolume
  • 1A PersistentVolume (PV) is a piece of storage provisioned in the cluster. It exists independently from any Pod.
  • 2Key fields: capacity.storage sets the size, accessModes defines how it can be mounted, and hostPath is the physical location on the node.
  • 3Try editing the YAML. Change storage: 1Gi to storage: 2Gi, then click Apply PV and watch the cluster state update.
๐Ÿ’ก Access Modes: ReadWriteOnce (RWO) = one node R/W. ReadOnlyMany (ROX) = many nodes read-only. ReadWriteMany (RWX) = many nodes R/W.
pv.yaml
๐Ÿ–ฅ Cluster State
PersistentVolume
PVC
Not created
Pod
Not created
terminal kubectl output โ— LIVE
๐Ÿ“‹ Step 2 Claim Storage with a PVC
  • 1A PVC is a request for storage. You say "I need 500Mi with ReadWriteOnce access" and Kubernetes finds a matching PV.
  • 2For binding to work, the PVC's storageClassName and accessModes must match the PV, and the PV capacity must be greater than or equal to the PVC request.
  • 3The PVC requests 500Mi but the PV has 1Gi. Kubernetes will still bind them since the PV is large enough.
pvc.yaml
๐Ÿ–ฅ Cluster State
PersistentVolume
PVC
Pending
Pod
Not created
terminal kubectl output โ— LIVE
๐Ÿš€ Step 3 Mount the Volume in a Pod
  • 1The Pod references the claim by name in volumes[].persistentVolumeClaim.claimName.
  • 2The volume is mounted inside the container at the path in volumeMounts[].mountPath.
  • 3Any file written to /usr/share/nginx/html inside the container will survive Pod deletion. That is the whole point.
pod.yaml
๐Ÿ–ฅ Cluster State Full View
PersistentVolume
PVC
Pod
Pending
terminal kubectl output โ— LIVE
โš™๏ธ kubectl Commands
get pvList all PersistentVolumes in the cluster
get pvcList all PVCs in current namespace
describe pv <name>Show detailed info about a PV
describe pvc <name>Show detailed info about a PVC
apply -f file.yamlCreate or update from YAML
delete pv <name>Delete a PersistentVolume
delete pvc <name>Delete a PVC
๐Ÿ“Š PV Status Lifecycle
AvailableFree resource, not yet bound to a PVC
BoundThe PV is bound to a PVC
ReleasedPVC was deleted, PV not yet reclaimed
FailedVolume failed auto-reclamation
๐Ÿ” Access Modes
ReadWriteOnceMounted R/W by a single node (RWO)
ReadOnlyManyMounted read-only by many nodes (ROX)
ReadWriteManyMounted R/W by many nodes (RWX)
ReadWriteOncePodMounted R/W by a single pod (RWOP)
โ™ป๏ธ Reclaim Policies
RetainData preserved after PVC deletion. Manual cleanup needed.
DeletePV and storage deleted automatically with the PVC.
RecycleDeprecated. Basic scrub before reuse.
๐Ÿ”— How PVC Finds a Matching PV
storageClassNameMust match between PV and PVC
accessModesPV must support all modes requested
capacityPV capacity must be greater than or equal to PVC request
volumeModeFilesystem or Block must match
๐Ÿ†
Achievement Unlocked