CKA StorageClass — PVC/PV binding and reclaim
StorageClass holds the recipe. PVC holds the request. PV holds reclaim.
<!-- hal:authoritative:yaml -->
On the exam, StorageClass holds the recipe. PVC holds the request. PV holds reclaim. Patch defaults until exactly one class is default.
§I - Frame
CKA storage stems still turn on three objects: StorageClass, PersistentVolumeClaim, PersistentVolume. Bootcamp Q14 is the primary drill today: create StorageClass local-storage with provisioner rancher.io/local-path, set volumeBindingMode: WaitForFirstConsumer, do not leave it default at create, then patch so it becomes the only default class. Do not modify existing Deployments or PVCs.
k8s_day_counter 20 is even, so CKA-emphasis. 09-21 was CKS ServiceAccount hardening. 09-18 was CKA Gateway. 09-12 was CKS PSA. Gateway, Ingress, NetworkPolicy, and PSA do not satisfy Q14.
Ops tonight colors the same objects with AKS disk.csi.azure.com. The exam may use local-path or another provisioner string. Memorize fields, not cloud brand names.
§II - Objective map
| Need | Mechanism |
|---|---|
| Dynamic recipe | StorageClass with provisioner, optional parameters, reclaimPolicy, volumeBindingMode |
| Request bytes | PersistentVolumeClaim with accessModes, resources.requests.storage, optional storageClassName |
| Bound volume | Controller provisions or matches a PersistentVolume; PVC phase Bound; spec.volumeName set |
| Default class | Annotation storageclass.kubernetes.io/is-default-class=true on exactly one SC |
| Survive claim delete | PV persistentVolumeReclaimPolicy: Retain (from class at create, or static PV) |
Access modes you must recognize: ReadWriteOnce (RWO), ReadOnlyMany (ROX), ReadWriteMany (RWX). Many block CSI volumes are RWO only.
§III - Q14 drill pattern (exam core)
- Write and apply the StorageClass (annotation false or omitted at create is fine):
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: local-storage
annotations:
storageclass.kubernetes.io/is-default-class: "false"
provisioner: rancher.io/local-path
volumeBindingMode: WaitForFirstConsumer
- Confirm:
kubectl get sc local-storageshows WaitForFirstConsumer and not default. - Patch local-storage to default true. Patch the previous default (often
local-path) to false. Q14 wants local-storage as the only default. - Re-check:
kubectl get scshows one(default). validate.bash counts defaults via JSON.
Do not touch Deployments or PVCs named in the stem. Binding mode is on the class, not on the claim.
§IV - Bind and reclaim discriminators
WaitForFirstConsumer vs Immediate. Wait delays provisioning until a Pod that uses the PVC is scheduled. Immediate provisions when the PVC is created. Multi-zone disks need Wait; eager Immediate is how affinity conflicts appear in Ops notes.
Default class. A PVC that omits storageClassName uses the default. Two defaults confuse admission. Zero defaults leave omitted-class claims Pending.
Reclaim Delete vs Retain (Poulton Ch.10). Delete (common StorageClass default) removes PV and back-end asset when the PVC is deleted. Retain keeps the PV (often Released) and the external volume; other claims cannot use it until you clear stale claimRef (Q1 adjacency). Recycle is gone from current API; do not write it.
Who owns reclaim. The policy lives on the PV (persistentVolumeReclaimPolicy). StorageClass reclaimPolicy is what dynamic provisioning copies at create. Read the PV after bind.
§V - Exam traps
- Answering Q14 with Ingress or Gateway YAML. Wrong domain.
- Leaving two defaults after the patch. Patch the old default false.
- Setting WaitForFirstConsumer on the PVC. Field belongs on StorageClass.
- Expecting RWX from a block volume stem. Match accessModes to the provisioner.
- Hunting reclaim on the PVC. Check the PV (and the class that minted it).
§VI - Study drill
- Run Bootcamp Q14 LabSetUp if present; apply SolutionNotes path cold.
- Run
validate.bash; fix until all checks pass (exists, provisioner, WaitForFirstConsumer, sole default). - Flash three lines: SC recipe / PVC request / PV reclaim; Wait vs Immediate; one default only.
- Optional adjacency: skim Q1 LabSetUp for Retain + claimRef reset (supporting, not tonight's primary apply).
Success: Q14 validate exit 0; you can explain PVC Pending under Wait with no Pod; you can state Delete vs Retain without guessing the PVC object.
§VII - Close instruction
File Q14 as the muscle memory. Pair: Ops AKS Azure Disk CSI classes; Dev Python StorageClass/PVC census. Maghrib owns quiz.html later.
Related
- Bootcamp: CKA Q14
- Ops: AKS Azure Disk CSI
- Dev: StorageClass + PVC census
- Prior CKA: Gateway (09-18)
- Prior CKA storage Retain (08-22)