K8S Storage Fundamentals¶
16 cards — 🟢 4 easy | 🟡 8 medium | 🔴 4 hard
🟢 Easy (4)¶
1. 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.2. 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.3. 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.4. 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 (8)¶
1. What reclaim policies are there?
Show answer
* Retain* Delete
Note: Recycle was deprecated in K8s 1.22 and removed in 1.24. Use dynamic provisioning instead.
2. Explain "Dynamic Provisioning" and "Static Provisioning"
Show answer
The main difference relies on the moment when you want to configure storage. For instance, if you need to pre-populate data in a volume, you choose static provisioning. Whereas, if you need to create volumes on demand, you go for dynamic provisioning.3. Which problems, volumes in Kubernetes solve?
Show answer
1. Sharing files between containers running in the same Pod2. Storage in containers is ephemeral - it usually doesn't last for long. For example, when a container crashes, you lose all on-disk data. Certain volumes allows to manage such situation by persistent volumes
4. Explain Volume Snapshots
Show answer
Volume snapshots let you create a copy of your volume at a specific point in time.5. True or False? Kubernetes manages data persistence
Show answer
False. Kubernetes provides the framework (PV, PVC, StorageClass) but does not manage the actual data persistence. Storage backends (cloud disks, NFS, Ceph) handle the physical storage.6. Explain ephemeral volume types vs. persistent volumes in regards to Pods
Show answer
Ephemeral volume types have the lifetime of a pod as opposed to persistent volumes which exist beyond the lifetime of a Pod.7. Explain "Persistent Volumes". Why do we need it?
Show answer
Persistent Volumes allow us to save data so basically they provide storage that doesn't depend on the pod lifecycle.8. What types of persistent volumes are there?
Show answer
* NFS* iSCSI
* CephFS
* ...
🔴 Hard (4)¶
1. How does Kubernetes handle storage orchestration, and what are the available storage classes?
Show answer
Storage Orchestration in Kubernetes:* Kubernetes abstracts storage using the StorageClass API.
* Storage classes define the type of storage, provisioning, and reclaim policies.
* Dynamic provisioning allows automatic creation of persistent volumes based on demand.
2. How does Kubernetes handle storage orchestration?
Show answer
* Storage Orchestration: Kubernetes abstracts storage through Persistent Volumes (PVs) and Persistent Volume Claims (PVCs).* Administrators provision PVs, and users request storage through PVCs.
* Storage Classes define the characteristics of the underlying storage, allowing dynamic provisioning.
* Kubernetes provides a flexible storage model, allowing applications to request and use storage resources without detailed knowledge of the underlying infrastructure.
3. Provide at least one use-case for each of the following volume types:
Show answer
* EmptyDir: You need a temporary data that you can afford to lose if the Pod is deleted. For example short-lived data required for one-time operations.* hostPath: You need access to paths on the host itself (like data from `/sys` or data generated in `/var/lib`)
4. What volume types are you familiar with?
Show answer
* emptyDir: created when a Pod assigned to a node and ceases to exist when the Pod is no longer running on that node* hostPath: mounts a path from the host itself. Usually not used due to security risks but has multiple use-cases where it's needed like access to some internal host paths (`/sys`, `/var/lib`, etc.)