By the end you'll know
- Why an
emptyDirvolume is for scratch space only - How a PersistentVolume (PV) and a PersistentVolumeClaim (PVC) find each other, and why a small claim can get a big volume
- What
Retainleaves behind when a claim is deleted, and how to reuse the volume - How a StorageClass and a provisioner make volumes on demand
- What
WaitForFirstConsumer, aDeletereclaim policy and a default StorageClass each do - Why a claim can't always be made bigger
Before you start
- You need: the cluster from Lesson 2, all nodes
Ready. - The output below is from real runs on November 29, 2026, in New York, on an Apple silicon Mac.
Storage is 10% of the exam, the smallest domain, but it's easy to get wrong under time pressure: the YAML is fiddly, and a claim that won't bind gives you very little to go on. This lesson builds storage by hand first, so the automatic version makes sense when it arrives.
Setup
(cp1)
k create ns st-lab
k config set-context --current --namespace=st-lab
k get storageclass
Context "kubernetes-admin@kubernetes" modified.
No resources found
set-context --current --namespace=st-labmakesst-labthe default for namespaced objects, as in Lesson 10. PersistentVolumes and StorageClasses have no namespace, so they're unaffected.- No StorageClasses. A fresh kubeadm cluster has no way to make storage on demand. Part 2 adds one.
A scratch volume: emptyDir
An emptyDir is an empty folder created when a pod starts, shared by all its containers, and deleted with the pod. Two containers, one writing and one reading:
(cp1)
cat > shared.yaml <<'EOF'
apiVersion: v1
kind: Pod
metadata: { name: shared }
spec:
containers:
- name: writer
image: busybox:1.37
command: ["sh", "-c", "while true; do date >> /data/log.txt; sleep 5; done"]
volumeMounts: [{ name: scratch, mountPath: /data }]
- name: reader
image: busybox:1.37
command: ["sh", "-c", "sleep 3600"]
volumeMounts: [{ name: scratch, mountPath: /data }]
volumes:
- name: scratch
emptyDir: {}
EOF
k apply -f shared.yaml
sleep 20
k exec shared -c reader -- tail -3 /data/log.txt
k delete pod shared
k apply -f shared.yaml
sleep 5
k exec shared -c reader -- cat /data/log.txt
volumesdeclares the volume once, for the pod.volumeMountssays where each container sees it. Both use/data, so the reader sees what the writer writes.-c readerpicks which containerexecruns in.
Sun Nov 29 18:45:35 UTC 2026
Sun Nov 29 18:45:40 UTC 2026
Sun Nov 29 18:45:45 UTC 2026
pod "shared" deleted from st-lab namespace
pod/shared created
Sun Nov 29 18:46:21 UTC 2026
The reader saw the writer's lines, so sharing works. After the pod was recreated, only the new pod's first line was there. The emptyDir went with the old pod. Use it for scratch files, caches, and handing files between containers in one pod. Never for data you want to keep.
A PersistentVolume and two claims
A PersistentVolume (PV) is a piece of storage the cluster knows about. It lives outside any pod, so it outlives them. A PersistentVolumeClaim (PVC) is a request for storage. Pods use claims, never PVs directly, and Kubernetes matches each claim to a volume.
One PV, made by hand, and two claims for it:
(cp1)
cat > pv.yaml <<'EOF'
apiVersion: v1
kind: PersistentVolume
metadata: { name: pv-manual }
spec:
capacity: { storage: 1Gi }
accessModes: [ReadWriteOnce]
persistentVolumeReclaimPolicy: Retain
storageClassName: manual
hostPath: { path: /mnt/pv-manual, type: DirectoryOrCreate }
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- { key: kubernetes.io/hostname, operator: In, values: [worker1] }
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata: { name: too-big }
spec:
accessModes: [ReadWriteOnce]
storageClassName: manual
resources: { requests: { storage: 2Gi } }
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata: { name: data }
spec:
accessModes: [ReadWriteOnce]
storageClassName: manual
resources: { requests: { storage: 500Mi } }
EOF
k apply -f pv.yaml
k get pv,pvc
k describe pvc too-big | tail -4
hostPathis a folder on a node, here/mnt/pv-manual.DirectoryOrCreatemakes it if it's missing. Fine for a lab; on a real cluster the data is stuck on one machine.nodeAffinityon the PV says the volume only exists onworker1, so any pod using it must run there. The scheduler handles that for you.accessModes: [ReadWriteOnce]means one node at a time can mount it read-write.ReadOnlyManylets many nodes read it, andReadWriteManylets many nodes write, which needs shared storage such as NFS.persistentVolumeReclaimPolicy: Retainkeeps the volume and its data when its claim is deleted.storageClassName: manualmust match between claim and volume. For hand-made PVs it's just a matching label: no StorageClass object calledmanualneeds to exist.
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS ...
persistentvolume/pv-manual 1Gi RWO Retain Bound st-lab/data manual ...
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS ...
persistentvolumeclaim/data Bound pv-manual 1Gi RWO manual ...
persistentvolumeclaim/too-big Pending manual ...
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning ProvisioningFailed 0s persistentvolume-controller storageclass.storage.k8s.io "manual" not found
dataasked for 500Mi and got 1Gi. A claim binds to a PV that's at least the size asked for, and a PV goes to one claim, whole. It isn't split.too-big(2Gi) is Pending: no volume is big enough.- The
"manual" not foundevent is a side effect, not the cause. With no PV to bind to, Kubernetes tried to make one through a StorageClass namedmanual. None exists, so that failed too. The real reason is plain: no 2Gi volume.
A claim binds when all three match: the storageClassName, an access mode the PV offers, and a size the PV can cover. When a claim stays Pending, check those three.
Data that outlives the pod
(cp1)
cat > app.yaml <<'EOF'
apiVersion: v1
kind: Pod
metadata: { name: app }
spec:
containers:
- name: app
image: busybox:1.37
command: ["sh", "-c", "echo saved-at-$(date +%T) >> /data/notes.txt; sleep 3600"]
volumeMounts: [{ name: data, mountPath: /data }]
volumes:
- name: data
persistentVolumeClaim: { claimName: data }
EOF
k apply -f app.yaml
sleep 10
k get pod app -o wide
k exec app -- cat /data/notes.txt
k delete pod app
k apply -f app.yaml
sleep 10
k exec app -- cat /data/notes.txt
persistentVolumeClaim: { claimName: data } is how a pod uses a claim. Each pod start adds one line to notes.txt.
NAME READY STATUS RESTARTS AGE IP NODE ...
app 1/1 Running 0 10s 10.244.235.181 worker1 ...
saved-at-18:48:52
pod "app" deleted from st-lab namespace
pod/app created
saved-at-18:48:52
saved-at-18:49:33
- The pod ran on
worker1without being told to: the PV'snodeAffinitydecided that. - The second pod saw the first pod's line. The data lives on the volume, not in the pod.
Retain, Released, and reusing a volume
Now delete the claim, and recreate it with the same name:
(cp1)
k delete pod app
k delete pvc data
k get pv pv-manual
k apply -f pv.yaml
k get pv,pvc
persistentvolumeclaim "data" deleted from st-lab namespace
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS ...
pv-manual 1Gi RWO Retain Released st-lab/data manual ...
persistentvolume/pv-manual unchanged
persistentvolumeclaim/too-big unchanged
persistentvolumeclaim/data created
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM ...
persistentvolume/pv-manual 1Gi RWO Retain Released st-lab/data ...
NAME STATUS VOLUME CAPACITY ...
persistentvolumeclaim/data Pending ...
persistentvolumeclaim/too-big Pending ...
Released: the claim is gone, butRetainkept the volume and its data, and the PV still records which claim it belonged to.- The new
dataclaim stays Pending, even with the same name. The PV remembers the old claim by its uid, a unique ID every object gets when it's created, and the new claim has a different one. Kubernetes won't hand one claim's data to another on its own.
You can see the remembered ID:
(cp1)
k get pv pv-manual -o jsonpath='{.spec.claimRef.uid}{"\n"}'
4d3ba769-9283-4114-a85b-fdc85d21db2a
-o jsonpath='...'prints one field instead of a table.{.spec.claimRef.uid}is the path: intospec, thenclaimRef(the PV's record of its claim), thenuid.{"\n"}adds a line break.
Two typos on the way to that command are worth showing, because they fail in opposite ways:
vagrant@cp1:~$ k get pv pv-manual -o jasonpath='{.spac.claimRef.uid}{"\n"}'
error: unable to match a printer suitable for the output format "jasonpath={.spac.claimRef.uid}{\"\\n\"}", allowed formats are: custom-columns,custom-columns-file,go-template,go-template-file,json,jsonpath,jsonpath-as-json,jsonpath-file,kyaml,name,template,templatefile,wide,yaml
vagrant@cp1:~$ k get pvc data -o jsonpath='{.metdate.uid}{"\n"}'
- A wrong format name is an error, and a useful one: it lists every valid
-oformat. - A wrong field name in the path prints nothing at all, with no error.
metdateshould bemetadata. When JSONPath gives you an empty answer, check the spelling before you believe it.k get ... -o yamlshows the real field names.
To let the claim have the volume, an admin removes the PV's record of its old claim:
(cp1)
k patch pv pv-manual --type=json -p='[{"op":"remove","path":"/spec/claimRef"}]'
k get pv,pvc
k apply -f app.yaml
sleep 10
k exec app -- cat /data/notes.txt
k patchchanges part of an object in place.--type=jsontakes a list of precise operations (JSON Patch). This one is a singleremoveof/spec/claimRef. JSON Patch writes paths with slashes; JSONPath uses dots.
persistentvolume/pv-manual patched
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM ...
persistentvolume/pv-manual 1Gi RWO Retain Available ...
NAME STATUS VOLUME ...
persistentvolumeclaim/data Pending ...
persistentvolumeclaim/too-big Pending ...
pod/app created
saved-at-18:48:52
saved-at-18:49:33
saved-at-18:56:19
- The PV went to
Available, and the claim was stillPendingat that instant. Binding is done by a controller on its next pass, a moment later. By the time the pod started, they were bound. - All three lines are there.
Retainkept the data through deleting the claim, and the same volume came back.
That patch is a decision, not a fix. Removing claimRef says "this data may go to whoever claims this volume next". On a real cluster, check whose data it is first.
Storage on demand: StorageClasses
Making each PV by hand doesn't scale. A StorageClass names a provisioner, a controller that makes volumes, plus the settings for the volumes it makes. A claim that names the class gets a volume made for it. That's dynamic provisioning.
First, clear part 1 away:
(cp1)
k delete pod app
k delete pvc data too-big
k delete pv pv-manual
Your cluster needs a provisioner. Rancher's local-path-provisioner makes folders on nodes, the dynamic version of hostPath. Releases before v0.0.34 had a critical security flaw, so pin a current one:
(cp1)
k apply -f https://raw.githubusercontent.com/rancher/local-path-provisioner/v0.0.37/deploy/local-path-storage.yaml
k -n local-path-storage get pods
k get storageclass
namespace/local-path-storage created
serviceaccount/local-path-provisioner-service-account created
role.rbac.authorization.k8s.io/local-path-provisioner-role created
clusterrole.rbac.authorization.k8s.io/local-path-provisioner-role created
rolebinding.rbac.authorization.k8s.io/local-path-provisioner-bind created
clusterrolebinding.rbac.authorization.k8s.io/local-path-provisioner-bind created
deployment.apps/local-path-provisioner created
storageclass.storage.k8s.io/local-path created
configmap/local-path-config created
NAME READY STATUS RESTARTS AGE
local-path-provisioner-7c7ff4f446-k469f 0/1 ContainerCreating 0 0s
NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE
local-path rancher.io/local-path Delete WaitForFirstConsumer false 0s
One file made a namespace, a ServiceAccount with its RBAC (Lesson 6), the controller, its settings, and the StorageClass. Each StorageClass column predicts something you're about to see:
PROVISIONER: which controller makes the volumes.RECLAIMPOLICY Delete: what happens to a volume when its claim is deleted.VOLUMEBINDINGMODE WaitForFirstConsumer: when the volume gets made.ALLOWVOLUMEEXPANSION false: whether claims can grow.
A claim that makes its own volume
(cp1)
cat > dyn.yaml <<'EOF'
apiVersion: v1
kind: PersistentVolumeClaim
metadata: { name: dyn }
spec:
accessModes: [ReadWriteOnce]
storageClassName: local-path
resources: { requests: { storage: 1Gi } }
---
apiVersion: v1
kind: Pod
metadata: { name: dyn-app }
spec:
containers:
- name: app
image: busybox:1.37
command: ["sh", "-c", "echo hello > /data/hi.txt; sleep 3600"]
volumeMounts: [{ name: data, mountPath: /data }]
volumes:
- name: data
persistentVolumeClaim: { claimName: dyn }
EOF
k get storageclass local-path -o jsonpath='{.volumeBindingMode}{"\n"}'
k apply -f dyn.yaml
k get pvc dyn
sleep 20
k get pvc dyn
k get pv
k exec dyn-app -- cat /data/hi.txt
WaitForFirstConsumer
persistentvolumeclaim/dyn created
pod/dyn-app created
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS ... AGE
dyn Pending local-path ... 0s
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS ... AGE
dyn Bound pvc-4e08f2b6-9ea5-4e46-ad9f-ae4fd11e67d3 1Gi RWO local-path ... 20s
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS ...
pvc-4e08f2b6-9ea5-4e46-ad9f-ae4fd11e67d3 1Gi RWO Delete Bound st-lab/dyn local-path ...
hello
- Pending at 0 seconds, Bound at 20. With
WaitForFirstConsumer, the volume isn't made until a pod uses the claim, so it can be made on the node where that pod runs. A Pending claim with this mode and no pod yet is normal. The other mode,Immediate, makes the volume as soon as the claim exists. - You never wrote that PV. The provisioner made
pvc-4e08f2b6-..., named after the claim, sized exactly as asked, with the class'sDeletepolicy.
The default class
(cp1)
k patch storageclass local-path -p '{"metadata":{"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
k get storageclass
- An annotation is a note on an object that tools read. This one marks the class as the default.
- No
--typethis time, so kubectl merges the patch into the object. Simpler than JSON Patch when you're adding or changing a field.
storageclass.storage.k8s.io/local-path patched
NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE
local-path (default) rancher.io/local-path Delete WaitForFirstConsumer false 4m14s
A claim that names no class now gets this one:
(cp1)
cat > noclass.yaml <<'EOF'
apiVersion: v1
kind: PersistentVolumeClaim
metadata: { name: noclass }
spec:
accessModes: [ReadWriteOnce]
resources: { requests: { storage: 100Mi } }
EOF
k apply -f noclass.yaml
k get pvc noclass -o jsonpath='{.spec.storageClassName}{"\n"}'
k delete pvc noclass
persistentvolumeclaim/noclass created
local-path
persistentvolumeclaim "noclass" deleted from st-lab namespace
The claim had no storageClassName, and Kubernetes filled in local-path. Like the default IngressClass in Lesson 9, it's stamped on when the claim is created. With no default class, a class-less claim only binds to a hand-made PV that also has no class.
Growing a claim
(cp1)
k patch pvc dyn -p '{"spec":{"resources":{"requests":{"storage":"2Gi"}}}}'
Error from server (Forbidden): persistentvolumeclaims "dyn" is forbidden: only dynamically provisioned pvc can be resized and the storageclass that provisions the pvc must support resize
Growing a claim needs two things: the StorageClass must have allowVolumeExpansion: true, and its provisioner must be able to resize. Cloud disks usually can. Local folders can't, so this class says false. Claims can never shrink.
Delete means delete
(cp1)
k delete pod dyn-app
k delete pvc dyn
sleep 10
k get pv
pod "dyn-app" deleted from st-lab namespace
persistentvolumeclaim "dyn" deleted from st-lab namespace
No resources found
The PV went with the claim, and its data with it. That's the Delete reclaim policy, and it's the usual default for dynamically made volumes. Compare part 1's Retain, which left a Released volume behind.
| Reclaim policy | When the claim is deleted | To reuse the volume |
|---|---|---|
Retain | The PV becomes Released; the data stays | An admin removes spec.claimRef, or copies the data and deletes the PV |
Delete | The PV and its storage are deleted | Nothing to reuse |
How the drills work
Each drill is a task to do from a blank terminal. Try it first, without looking. Then open "Show the fast way" to compare your commands, and read the notes under them: they cover the part people usually get wrong. Repeat a drill a few days later until you can do it cold, because the exam leaves little time to look things up.
The drills
Create a 1Gi PersistentVolume named pv-log using the host folder /mnt/log, with access mode ReadWriteOnce and storage class manual. Then a 500Mi claim named log-claim in namespace NS that binds to it.
Show the fast way
apiVersion: v1
kind: PersistentVolume
metadata: { name: pv-log }
spec:
capacity: { storage: 1Gi }
accessModes: [ReadWriteOnce]
storageClassName: manual
hostPath: { path: /mnt/log }
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata: { name: log-claim, namespace: NS }
spec:
accessModes: [ReadWriteOnce]
storageClassName: manual
resources: { requests: { storage: 500Mi } }
k apply -f pv.yaml
k get pv,pvc -n NS
The claim shows 1Gi once bound: it gets the whole PV. If it stays Pending, compare the class name, the access mode and the size. Copy the shapes from the docs page "Configure a Pod to Use a PersistentVolume for Storage".
Run a pod named logger in namespace NS that mounts claim log-claim at /var/log/app, and prove a file written there survives the pod being recreated.
Show the fast way
apiVersion: v1
kind: Pod
metadata: { name: logger, namespace: NS }
spec:
containers:
- name: logger
image: busybox:1.37
command: ["sh", "-c", "date >> /var/log/app/run.txt; sleep 3600"]
volumeMounts: [{ name: logs, mountPath: /var/log/app }]
volumes:
- name: logs
persistentVolumeClaim: { claimName: log-claim }
k apply -f logger.yaml
k exec -n NS logger -- cat /var/log/app/run.txt
k delete pod -n NS logger
k apply -f logger.yaml
k exec -n NS logger -- cat /var/log/app/run.txt
The volume's name links volumes to volumeMounts; claimName links the volume to the claim. Two lines in the file after the restart prove it.
A PV with reclaim policy Retain shows Released after its claim was deleted. A new claim for it stays Pending. Make the volume available again.
Show the fast way
k get pv NAME
k get pv NAME -o jsonpath='{.spec.claimRef.name}{"\n"}'
k patch pv NAME --type=json -p='[{"op":"remove","path":"/spec/claimRef"}]'
k get pv,pvc -A
The PV still points at its old claim, by uid. Removing spec.claimRef makes it Available, and the waiting claim binds a moment later. The old data is still there.
Make StorageClass fast the cluster's default, then create a 200Mi claim named cache in namespace NS without naming a class, and confirm which class it got.
Show the fast way
k patch storageclass fast -p '{"metadata":{"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
k get storageclass
apiVersion: v1
kind: PersistentVolumeClaim
metadata: { name: cache, namespace: NS }
spec:
accessModes: [ReadWriteOnce]
resources: { requests: { storage: 200Mi } }
k apply -f cache.yaml
k get pvc cache -n NS -o jsonpath='{.spec.storageClassName}{"\n"}'
Only one class should be the default. If another already is, set its annotation to "false" first. With WaitForFirstConsumer, the claim stays Pending until a pod uses it; that's expected.
Grow claim data in namespace NS from 1Gi to 2Gi. If it's refused, find out why.
Show the fast way
k patch pvc data -n NS -p '{"spec":{"resources":{"requests":{"storage":"2Gi"}}}}'
k get pvc data -n NS -o jsonpath='{.spec.storageClassName}{"\n"}'
k get storageclass CLASS -o jsonpath='{.allowVolumeExpansion}{"\n"}'
Expansion needs allowVolumeExpansion: true on the StorageClass, and a provisioner that can resize. If that JSONPath prints an empty line, the field isn't set, which means no expansion: on local-path it prints nothing, though k get storageclass shows false in its table. Claims can grow but never shrink. A hand-made PV with no provisioner can't be resized this way.
On exam day
- Copy PV, PVC and pod-volume YAML from the docs, and change the names. It's short, but the nesting is easy to get wrong.
- When a claim is Pending, check three things against the PV: class name, access mode, size. Then the StorageClass's binding mode.
k get pvis cluster-wide;k get pvcneeds the namespace.- Read the reclaim policy before deleting a claim whose data matters.
- Check JSONPath answers aren't empty before writing them to a file.
Clean up
(cp1)
k config set-context --current --namespace=default
k delete ns st-lab
rm shared.yaml pv.yaml app.yaml dyn.yaml noclass.yaml
k config view --minify | grep namespace
Context "kubernetes-admin@kubernetes" modified.
namespace "st-lab" deleted
namespace: default
I kept the provisioner installed, and it's still the default class. It's small, and Lesson 12's mock exam can use it. To remove it, delete what the same file created: k delete -f https://raw.githubusercontent.com/rancher/local-path-provisioner/v0.0.37/deploy/local-path-storage.yaml.
In real life
- Cloud clusters come with a default StorageClass for the provider's disks, so claims just work. Bare-metal clusters need something like Longhorn, Rook-Ceph or an NFS provisioner.
Deleteis the default for dynamic volumes, so deleting a claim deletes the data. For databases, teams use aRetainclass, or take backups (Velero, or the database's own) before anything is deleted.- Local storage ties a pod to one node. If that node dies, the data is stuck. Fine for caches and labs; not for anything you'd miss.
- StatefulSets give each replica its own claim from a template, which is how databases usually get their storage.
Spot the problem
Work out what's wrong before you read the explanation.
"The claim has been Pending for ten minutes, but there's a PV right there." A 5Gi claim with class standard sits Pending next to an Available 10Gi PV with class manual. Why? The class names differ. A claim only binds to a PV with the same storageClassName. Size and access mode must fit too.
"We deleted the claim by mistake, recreated it, and it's empty." A team's claim used the cluster's default class. Someone deleted it, recreated it with the same name, and the app's data is gone. Why? The default class uses Delete. The volume and its data were removed with the old claim, and the new claim got a brand new, empty volume.
"Our new claim is Pending and nothing is broken." A claim using a WaitForFirstConsumer class has been Pending for an hour, and its events show no errors. What's going on? No pod uses it yet. The volume is made when the first pod that mounts the claim is scheduled.
Keep this
| To | Use |
|---|---|
| List volumes and claims | k get pv,pvc -A |
| Why a claim is Pending | k describe pvc NAME -n NS, then compare class, access mode and size with the PV |
| List classes, and the default | k get storageclass |
| Make a class the default | Annotation storageclass.kubernetes.io/is-default-class: "true" |
| Reuse a Released PV | k patch pv NAME --type=json -p='[...remove /spec/claimRef...]' |
| Grow a claim | Raise spec.resources.requests.storage; the class needs allowVolumeExpansion: true |
| Scratch space shared in a pod | emptyDir, lost with the pod |
| One field of an object | -o jsonpath='...'; an empty answer usually means a typo |
Where you are now
You've watched an emptyDir die with its pod, bound a claim to a volume you made by hand, kept data through a claim's deletion with Retain, and taken a Released volume back. You've installed a provisioner, watched a claim wait for its pod and then get a volume made for it, made a default class, been refused a resize, and seen Delete remove a volume with its claim. That's every exam domain covered. Lesson 12 puts them together in a timed mock exam.
Check yourself
A 500Mi claim binds to a 1Gi PersistentVolume. What capacity does the claim show?
A PV with reclaim policy Retain shows Released. You recreate its claim with the same name, and the claim stays Pending. Why?
A claim using a WaitForFirstConsumer class is Pending, with no errors. What do you do?
A team deletes a claim from the cluster's default class and recreates it. The new claim is empty. What happened?
Growing a claim from 1Gi to 2Gi is refused: the storageclass must support resize. What's needed?
k get pvc data -o jsonpath='{.metdate.uid}' prints an empty line and no error. What's wrong?
Key terms
- Volume: storage mounted into a pod's containers, declared under
volumesand placed withvolumeMounts. - emptyDir: a scratch folder that lives and dies with its pod.
- PersistentVolume (PV): a cluster-wide piece of storage that outlives pods.
- PersistentVolumeClaim (PVC): a namespaced request for storage, bound to one PV.
- Access modes: ReadWriteOnce (one node writes), ReadOnlyMany (many nodes read), ReadWriteMany (many nodes write).
- Reclaim policy: what happens to a PV when its claim is deleted:
Retainkeeps it,Deleteremoves it. - Released: a
RetainPV whose claim is gone; it can't bind again until an admin clearsclaimRef. - StorageClass: names a provisioner and settings, so claims get volumes made on demand.
- Provisioner: the controller that makes volumes for a StorageClass.
- Volume binding mode:
Immediatemakes the volume with the claim;WaitForFirstConsumerwaits for a pod. - Default StorageClass: the class given to claims that name none, set by an annotation.
Go deeper
- Volumes (opens in a new tab), including emptyDir and hostPath.
- Persistent Volumes (opens in a new tab): binding, access modes, reclaim policies and expansion.
- Storage Classes (opens in a new tab), including binding modes and the default class.
- Configure a Pod to Use a PersistentVolume for Storage (opens in a new tab), the page to copy from.
- Local Path Provisioner (opens in a new tab) on GitHub.