Skip to content

K8S Storage

← Back to all decks

39 cards — 🟢 8 easy | 🟔 12 medium | šŸ”“ 8 hard

🟢 Easy (8)

1. What is the relationship between a PersistentVolume (PV) and a PersistentVolumeClaim (PVC)?

Show answer A PV is a cluster-level storage resource. A PVC is a namespace-scoped request for storage. Pods reference PVCs, and Kubernetes binds PVCs to matching PVs based on access mode, storage class, and capacity. The binding is exclusive.

Remember: Storage abstraction: StorageClass→PV→PVC→Pod mount. Dynamic provisioning automates PV.

2. What are the three classic PersistentVolume access modes and what does each allow?

Show answer ReadWriteOnce (RWO): mounted read-write by a single node. ReadOnlyMany (ROX): mounted read-only by many nodes. ReadWriteMany (RWX): mounted read-write by many nodes. RWO is the most common since block storage is single-attach.

Remember: RWO=ReadWriteOnce, ROX=ReadOnlyMany, RWX=ReadWriteMany. O=One, X=Many.

3. What is the purpose of a StorageClass in Kubernetes?

Show answer A StorageClass defines how storage is provisioned. It names a provisioner (CSI driver), sets provider-specific parameters (disk type, IOPS), configures the reclaim policy, and controls volume binding mode. It enables dynamic provisioning so admins do not need to pre-create PVs.

Remember: StorageClass = PV factory. Dynamic provisioning — no pre-created PVs needed.

Example: `kubectl get sc`. Default SC handles PVCs that omit storageClassName.

4. What are the PersistentVolume reclaim policies and when should you use each?

Show answer Retain: PV persists after PVC deletion, admin must manually reclaim (use for databases). Delete: PV and underlying storage are deleted when PVC is deleted (use for ephemeral workloads). Recycle is deprecated and should not be used.

Remember: Retain(manual), Delete(auto), Recycle(deprecated). Dynamic default=Delete.

Gotcha: Retain→PV becomes Released, not Available. Manual intervention needed.

5. True or False? Kubernetes provides data persistence out of the box, so when you restart a pod, data is saved

Show answer False. Kubernetes does NOT provide data persistence by default. Container filesystems are ephemeral — data is lost when a Pod restarts. You need PersistentVolumes (PV/PVC) for durable storage.

Under the hood: PV = cluster-scoped storage (EBS, NFS, local). PVC = namespace-scoped request that binds to a matching PV.

Remember: Storage abstraction: StorageClass→PV→PVC→Pod mount. Dynamic provisioning automates PV.

6. True or False? A volume defined in Pod can be accessed by all the containers of that Pod

Show answer True. A volume defined in a Pod spec is accessible to all containers in that Pod. Each container mounts it via volumeMounts, and they can share data through it.

Remember: Storage abstraction: StorageClass→PV→PVC→Pod mount. Dynamic provisioning automates PV.

7. What is a volume in regards to Kubernetes?

Show answer A directory accessible by the containers inside a certain Pod and containers. The mechanism responsible for creating the directory, managing it, ... mainly depends on the volume type.

Remember: Storage abstraction: StorageClass→PV→PVC→Pod mount. Dynamic provisioning automates PV.

8. What is a Persistent Volume (PV) and Persistent Volume Claim (PVC) in Kubernetes?

Show answer * Persistent Volume (PV):
* Represents a piece of storage in the cluster that has been provisioned by an administrator.
* Can be used to store data independently of any particular pod.
* Provides a way to manage storage resources in a cluster.
* Persistent Volume Claim (PVC):
* Represents a request for storage by a user or pod.
* Binds to a Persistent Volume, making the storage available to the pod.
* Allows for dynamic provisioning of storage resources.
Persistent Volumes and Persistent Volume Claims provide a mechanism for decoupling storage from pod lifecycles.

🟔 Medium (12)

1. Explain the dynamic provisioning flow when a pod requests storage via a PVC.

Show answer 1) Pod references a PVC. 2) PVC references a StorageClass. 3) Kubernetes calls the CSI driver named in the StorageClass. 4) The driver creates the underlying volume. 5) A PV is automatically created and bound to the PVC. 6) The volume is mounted into the pod. WaitForFirstConsumer delays this until a pod is scheduled, ensuring zone alignment.

Remember: Storage abstraction: StorageClass→PV→PVC→Pod mount. Dynamic provisioning automates PV.

2. What is the difference between Immediate and WaitForFirstConsumer volume binding modes?

Show answer Immediate provisions the volume as soon as the PVC is created. WaitForFirstConsumer delays provisioning until a pod using the PVC is scheduled to a node. WaitForFirstConsumer is critical on cloud providers to ensure the volume is created in the same availability zone as the node.

Remember: Storage abstraction: StorageClass→PV→PVC→Pod mount. Dynamic provisioning automates PV.

3. How does StatefulSet storage work with volumeClaimTemplates?

Show answer StatefulSets use volumeClaimTemplates to create one PVC per replica, named