A PersistentVolume (PV) is a piece of storage in the cluster that has been provisioned by an administrator or dynamically. It is a resource in the cluster just like a node and is used to store data persistently beyond the lifecycle of a pod.
Click to reveal answer
intermediate
Which key fields are required in a PersistentVolume YAML definition?
The key fields include: apiVersion, kind (PersistentVolume), metadata (name), spec (capacity, accessModes, persistentVolumeReclaimPolicy, storageClassName, and the actual storage details like hostPath, nfs, etc.).
Click to reveal answer
beginner
What does the 'accessModes' field specify in a PersistentVolume?
The 'accessModes' field defines how the volume can be mounted by pods. Common modes are ReadWriteOnce (mounted by a single node), ReadOnlyMany (mounted read-only by many nodes), and ReadWriteMany (mounted read-write by many nodes).
Click to reveal answer
intermediate
What is the purpose of 'persistentVolumeReclaimPolicy' in a PV?
It tells Kubernetes what to do with the volume after the claim is released. Common policies are Retain (keep data), Recycle (basic scrub), and Delete (remove volume).
Click to reveal answer
beginner
Show a simple example of a PersistentVolume definition using hostPath.
A. hostPath volumes cannot have storageClassName set
B. accessModes value ReadWriteOnce is invalid
C. Missing volumeMode field
D. persistentVolumeReclaimPolicy Delete is not allowed
Solution
Step 1: Check hostPath volume restrictions
hostPath volumes do not support storageClassName because they are local paths.
Step 2: Validate other fields
accessModes and reclaim policy values are valid; volumeMode is optional.
Final Answer:
hostPath volumes cannot have storageClassName set -> Option A
Quick Check:
hostPath + storageClassName = error [OK]
Hint: hostPath volumes must not set storageClassName [OK]
Common Mistakes:
Assuming volumeMode is mandatory
Thinking accessModes ReadWriteOnce is invalid
Believing Delete reclaim policy is disallowed
5. You want to create a PersistentVolume that allows multiple pods to read and write simultaneously and automatically deletes the volume when released. Which YAML snippet correctly defines these requirements?