Day 29/40 Kubernetes Volume Simplified | Persistent Volume, Persistent Volume Claim & Storage Class
About this video
### Comprehensive Final Summary This document provides a detailed overview of storage concepts in Kubernetes, focusing on key components like Persistent Volumes (PV), Persistent Volume Claims (PVC), and Storage Classes. The content is part of a broader series (CK 2024) aimed at deepening understanding of Kubernetes storage mechanisms. Prior knowledge of Docker storage is beneficial but not essential. #### **Introduction to Storage in Kubernetes** The video introduces fundamental storage concepts within Kubernetes, including PVs, PVCs, and Storage Classes. These elements are crucial for managing data persistence in containerized environments, ensuring that data survives beyond the lifecycle of individual pods. #### **Hands-On Setup** Practical learning is emphasized through a GitHub repository containing notes, diagrams, and sample code. The instructor demonstrates creating a Redis pod YAML file with an `emptyDir` volume type. This temporary storage solution is tied to the pod's lifecycle, meaning data is lost when the pod is deleted. #### **Persistent Storage Concepts** - **Persistent Volume (PV)**: A cluster-wide resource provisioned by the storage administrator. - **Persistent Volume Claim (PVC)**: A user request for storage, specifying size and access modes such as ReadWriteOnce, ReadOnlyMany, and ReadWriteMany. - Binding occurs when a PVC matches an available PV based on capacity and access mode criteria. #### **Access Modes and Reclaim Policies** Access modes dictate how pods can interact with storage, whether it be single or multiple nodes. Reclaim policies determine the fate of a PV after its associated PVC is deleted: - **Retain**: Keeps the PV but marks it as released. - **Delete**: Removes the PV and its associated storage. - **Recycle**: Prepares the PV for reuse. #### **Demo: Creating PV, PVC, and Pod** A practical demonstration involves creating a PV with 1GB of storage using `hostPath`, suitable only for single-node clusters. A PVC requests 500MB of storage, and the binding is verified via `kubectl get pv` and `kubectl get pvc`. A pod is then created, using the PVC to mount storage at `/usr/share/nginx/html`. #### **HostPath Limitations** `hostPath` is unsuitable for multi-node clusters as it maps to a specific node’s filesystem. Solutions include using node selectors, taints, tolerations, or explicitly scheduling pods on the control plane node. #### **Pod Scheduling on Control Plane** By default, custom workloads cannot be scheduled on control plane nodes. However, this section explains how to use `hostPath` for serving web pages from a local directory, highlighting its limitations, especially in multi-node setups. #### **Storage Classes and Dynamic Provisioning** To address the limitations of `hostPath`, **Storage Classes** are introduced, enabling dynamic provisioning of storage from cloud providers or external data centers (e.g., AWS EBS, Azure File, NFS). A **Storage Class** defines the type of storage provisioned using a **provisioner**, linking it to a physical storage location. There are two types of provisioning: 1. **Static Provisioning**: Manually specifying PV and PVC details. 2. **Dynamic Provisioning**: Automatically creating PVs and PVCs based on Storage Class definitions. If no Storage Class is specified, Kubernetes defaults to a predefined one, abstracting storage management and making it scalable and flexible across various environments. #### **Conclusion** The instructor concludes by encouraging viewers to explore examples and complete related tasks in the Day 29 folder, reinforcing the importance of hands-on practice in mastering Kubernetes storage concepts. This comprehensive approach ensures learners gain both theoretical knowledge and practical skills necessary for effective storage management in Kubernetes environments.
Course: Certified Kubernetes Administrator Full Course For beginners | CKA 2025
This playlist contains the complete CKA series for beginners, based on the latest 2025 curriculum. It includes 40+ videos with hands-on demos, assignments, and exam-based scenarios. We will cover everything from the basics to the Advanced, including fundamental concepts such as Docker, containers, Docker storage and networking, DNS, etc.
View Full Course