World map

 

BM: Baca dalam Bahasa Melayu

World K4: Notes, Lockers & Packages

Lockers: PV and PVC

You will learn: to ask for storage with a PVC, so data outlives the pod that wrote it.

Checked with Kubernetes 1.37 on 31 Oct 2026

The problem

You are here: cluster kind-dev namespace default
The cashier writes an order into /tmp inside its box. The pod is replaced. cat says: No such file or directory. Terminal output: $ kubectl exec cashier -- sh -c 'echo nasi lemak x2 >> /tmp/orders.txt' $ kubectl delete pod cashier pod "cashier" deleted from default namespace $ kubectl apply -f cashier.yaml pod/cashier created $ kubectl wait --for=condition=Ready pod/cashier --timeout=60s pod/cashier condition met $ kubectl exec cashier -- cat /tmp/orders.txt cat: can't open '/tmp/orders.txt': No such file or directory command terminated with exit code 1

The cashier kept today’s orders inside its box. The pod was replaced. Every order is gone. You need a locker that stays.

Watch

Tap the line that says how big the locker is.

0 of 1 found

You fill in a locker request slip. That slip is a PersistentVolumeClaim (PVC): A locker request slip, like "I need 1Gi". Kubernetes finds or makes a PV for it. (PVC). It says how big, and how many may use it.

Predict

You apply the claim. kubectl get pvc says Pending. Why?

Pick one answer.

Try it

Apply the claim, then the cashier pod that uses it. Check the claim again.

You are here: cluster kind-dev namespace default
Stalls: 3. Trays: 0 (0 ready). Waiting for a stall: 0.
dev-control-planeOpenManager

No trays here.

dev-workerOpen

No trays here.

dev-worker2Open

No trays here.

Time: +0s (sped up)

Watch

You are here: cluster kind-dev namespace default
get pvc shows orders Bound to a volume named pvc- and a long id. get pv shows that volume, 1Gi, RWO, claimed by default/orders. Terminal output: $ kubectl get pvc NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS VOLUMEATTRIBUTESCLASS AGE orders Bound pvc-14148d20-7191-41bd-b0ee-9b62e9454543 1Gi RWO standard <unset> 14s $ kubectl get pv NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS VOLUMEATTRIBUTESCLASS REASON AGE pvc-14148d20-7191-41bd-b0ee-9b62e9454543 1Gi RWO Delete Bound default/orders standard <unset> 14s

The slip is now Bound to a PersistentVolume (PV): The real locker in the store room: storage that outlives pods. (PV): the real locker. Nobody built it by hand. The next lesson shows who did.

Try it

The cashier wrote an order into the locker. Replace the pod. Then read the orders.

You are here: cluster kind-dev namespace default
Stalls: 3. Trays: 1 (1 ready). Waiting for a stall: 0.
dev-control-planeOpenManager

No trays here.

dev-workerOpen
  • cashier
dev-worker2Open

No trays here.

Time: +0s (sped up)

Check

PV or PVC? Sort each one.

Drag a card into a box. Or tap the card, then tap the box.

      You did it!

      You can now keep data in a locker that outlives its pod.

      Go deeper (optional)

      Careful: kind’s standard class has reclaimPolicy: Delete. Delete the claim, and the PV and its data go too. Use Retain for data you must keep. While a pod uses the claim, deleting it waits. The claim shows Terminating until that pod is gone.

      Real rep (optional), on a practice kind cluster:

      Real mission

      1. kubectl apply -f claim.yaml
      2. kubectl apply -f cashier.yaml
      3. kubectl get pvc,pv
      4. kubectl exec cashier -- sh -c 'echo teh tarik >> /data/orders.txt'
      5. kubectl delete -f cashier.yaml -f claim.yaml

      0 of 6 steps done · Your ticks are saved.