Storage Quiz
Quiz
volumes:
- name: cache
emptyDir:
sizeLimit: 1Gitype: ___ ensures the path exists as a directory before mounting.type: Directory validation ensures that the specified path exists on the host and is actually a directory before the volume is mounted. Other types include File, FileOrCreate, DirectoryOrCreate, and Socket.type: Directory validation ensures that the specified path exists on the host and is actually a directory before the volume is mounted. Other types include File, FileOrCreate, DirectoryOrCreate, and Socket.PersistentVolume (PV): A cluster-level storage resource provisioned by administrators. It represents actual storage (NFS, EBS, etc.) with specific capacity and access modes.
PersistentVolumeClaim (PVC): A user’s request for storage. It’s like a “storage voucher” that asks for specific storage requirements (size, access mode). Kubernetes binds PVCs to suitable PVs.
Analogy: PV is like a parking spot, PVC is like a parking ticket requesting a spot.
Did you get it right?
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: my-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: ___StorageClass enables dynamic provisioning - when a PVC references a StorageClass, the provisioner automatically creates a matching PV without manual administrator intervention. This solves the scalability problem of manually pre-creating PVs.StorageClass enables dynamic provisioning - when a PVC references a StorageClass, the provisioner automatically creates a matching PV without manual administrator intervention. This solves the scalability problem of manually pre-creating PVs.reclaimPolicy: Retain, when a PVC is deleted, the PV is NOT automatically deleted. It enters a ‘Released’ state and retains the data, allowing administrators to manually reclaim or backup the data. Kubernetes supports three reclaim policies: (1) Retain — PV is kept in ‘Released’ state after PVC deletion, data preserved, manual cleanup required; (2) Delete — PV and its underlying storage asset are automatically deleted when the PVC is deleted; (3) Recycle (deprecated) — performs a basic scrub (rm -rf) on the volume and makes it available again for a new claim.reclaimPolicy: Retain, when a PVC is deleted, the PV is NOT automatically deleted. It enters a ‘Released’ state and retains the data, allowing administrators to manually reclaim or backup the data. Kubernetes supports three reclaim policies: (1) Retain — PV is kept in ‘Released’ state after PVC deletion, data preserved, manual cleanup required; (2) Delete — PV and its underlying storage asset are automatically deleted when the PVC is deleted; (3) Recycle (deprecated) — performs a basic scrub (rm -rf) on the volume and makes it available again for a new claim.volumeBindingMode: WaitForFirstConsumer. When does the actual storage get provisioned?apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: fast-ssd
provisioner: ebs.csi.aws.com
volumeBindingMode: WaitForFirstConsumerWaitForFirstConsumer delays volume provisioning until a pod using the PVC is scheduled. This ensures the volume is created in the correct availability zone/region where the pod will run, which is especially important for cloud providers with zone-specific storage. Kubernetes supports two volumeBindingMode options: (1) Immediate — PV is provisioned and bound as soon as the PVC is created, regardless of whether any pod will use it (can cause zone mismatch issues in multi-zone clusters); (2) WaitForFirstConsumer — PV provisioning is delayed until a pod using the PVC is scheduled to a node, ensuring the volume is created in the correct zone.WaitForFirstConsumer delays volume provisioning until a pod using the PVC is scheduled. This ensures the volume is created in the correct availability zone/region where the pod will run, which is especially important for cloud providers with zone-specific storage. Kubernetes supports two volumeBindingMode options: (1) Immediate — PV is provisioned and bound as soon as the PVC is created, regardless of whether any pod will use it (can cause zone mismatch issues in multi-zone clusters); (2) WaitForFirstConsumer — PV provisioning is delayed until a pod using the PVC is scheduled to a node, ensuring the volume is created in the correct zone.CSI (Container Storage Interface) is a standardized interface that allows Kubernetes to integrate with different storage systems through external plugins called CSI drivers. It decouples storage logic from Kubernetes core, enabling vendors to develop and maintain storage integrations independently without modifying Kubernetes.
Before CSI: Storage plugins were built into Kubernetes (in-tree) — required a Kubernetes release to update.
With CSI: Storage runs as external drivers (out-of-tree) — can be updated independently, works across orchestrators (Kubernetes, Mesos, etc.).
Example: AWS EBS CSI driver (ebs.csi.aws.com) can be updated by AWS without waiting for Kubernetes releases.
Did you get it right?
volumes:
- name: storage
persistentVolumeClaim:
claimName: ___volumes with persistentVolumeClaim.claimName pointing to the PVC’s name. The pod must be in the same namespace as the PVC.volumes with persistentVolumeClaim.claimName pointing to the PVC’s name. The pod must be in the same namespace as the PVC.NFS, local, and Ceph (via Rook) provisioners are cloud-agnostic and work in on-premise or multi-cloud environments. AWS EBS, GCP Persistent Disk, and Azure Disk are cloud-specific and tied to their respective platforms. Rook-Ceph (rook-ceph.rbd.csi.ceph.com) is a popular open-source distributed storage system that runs entirely within Kubernetes and is commonly used for on-premise clusters.NFS, local, and Ceph (via Rook) provisioners are cloud-agnostic and work in on-premise or multi-cloud environments. AWS EBS, GCP Persistent Disk, and Azure Disk are cloud-specific and tied to their respective platforms. Rook-Ceph (rook-ceph.rbd.csi.ceph.com) is a popular open-source distributed storage system that runs entirely within Kubernetes and is commonly used for on-premise clusters.ReadWriteOnce (RWO) means the volume can be mounted as read-write by a single node, not a single pod. Multiple pods on the same node can share a RWO volume. If you need to restrict to a single pod across the entire cluster, use ReadWriteOncePod.ReadWriteOnce (RWO) means the volume can be mounted as read-write by a single node, not a single pod. Multiple pods on the same node can share a RWO volume. If you need to restrict to a single pod across the entire cluster, use ReadWriteOncePod.reclaimPolicy specifies what should happen to a PersistentVolume when the PersistentVolumeClaim bound to it is deleted. Options are Retain, Delete, or Recycle (deprecated).reclaimPolicy specifies what should happen to a PersistentVolume when the PersistentVolumeClaim bound to it is deleted. Options are Retain, Delete, or Recycle (deprecated).apiVersion: apps/v1
kind: StatefulSet
metadata:
name: db
spec:
replicas: 5
volumeClaimTemplates:
- metadata:
name: data
spec:
storageClassName: fast
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 10GiDynamic Provisioning automatically creates PersistentVolumes on-demand when a PVC is created, without manual administrator intervention.
How it works:
- User creates PVC referencing a StorageClass
- StorageClass’s provisioner (e.g., AWS EBS CSI) is triggered
- Provisioner creates actual storage in backend (e.g., EBS volume)
- Provisioner creates PV object in Kubernetes
- Kubernetes binds PVC to the new PV
- Pod can use storage immediately
Benefits:
- Scalable: No need to pre-create PVs
- Automated: Reduces manual operations
- Efficient: Storage created only when needed
vs. Static Provisioning: Admin manually creates PVs, users claim from existing pool.
Did you get it right?
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: expandable
provisioner: ebs.csi.aws.com
___: trueallowVolumeExpansion: true field in a StorageClass permits PVCs using that StorageClass to be expanded after creation by editing the PVC’s storage request. Not all storage backends support this feature.allowVolumeExpansion: true field in a StorageClass permits PVCs using that StorageClass to be expanded after creation by editing the PVC’s storage request. Not all storage backends support this feature.subPath field in a volumeMount?subPath field allows mounting a specific file or subdirectory from a volume rather than mounting the entire volume root. This is useful when multiple containers need different subdirectories from the same volume, or to avoid mounting over existing directories.subPath field allows mounting a specific file or subdirectory from a volume rather than mounting the entire volume root. This is useful when multiple containers need different subdirectories from the same volume, or to avoid mounting over existing directories.1. Retain (default for manually created PVs):
- PV is not deleted when PVC is deleted
- Data is preserved
- PV status becomes ‘Released’ (not ‘Available’)
- Admin must manually clean up and reclaim
- Use for: Critical data requiring manual backup
2. Delete (default for dynamic provisioning):
- PV and underlying storage are automatically deleted when PVC is deleted
- Data is permanently lost
- Use for: Temporary data, development environments
3. Recycle (DEPRECATED):
- Basic scrub (rm -rf on the volume)
- PV becomes available for new claims
- No longer recommended; use Delete + dynamic provisioning instead
Did you get it right?