Mastering Kubernetes Persistent Storage (PV & PVC)

🚀 Day 26-28 of #90DaysOfDevOps — Mastering Kubernetes Persistent Storage (PV & PVC) Today I worked on one of the most important real-world Kubernetes concepts: Persistent Volumes (PV) and Persistent Volume Claims (PVC) — and this is where Kubernetes truly starts feeling like production engineering. 🔍 Problem I Explored Containers are ephemeral. I created a Pod using emptyDir and wrote timestamps to a file. Deleted the Pod → recreated it → data was gone ❌ 👉 Lesson: emptyDir is tied to the Pod lifecycle → not suitable for databases or stateful applications. 💡 Solution: Persistent Storage with PV & PVC Implemented: PersistentVolume (PV) → actual storage resource PersistentVolumeClaim (PVC) → request abstraction 📌 Flow: Pod → PVC → PV → Physical Storage ⚙️ What I Practiced ✅ Static Provisioning Created PV manually (hostPath) Created PVC → successfully bound Mounted PVC in Pod → data persisted even after Pod deletion ✅ 🚀 Dynamic Provisioning (Real-world scenario) Used default StorageClass (standard) Created ONLY PVC → Kubernetes auto-created PV Learned about: provisioner: rancher.io/local-path reclaimPolicy: Delete volumeBindingMode: WaitForFirstConsumer 👉 Key Insight: PV is created only when a Pod uses the PVC 🔥 Major Debugging Moment PVC was stuck in Pending Root cause: ❌ StorageClass mismatch Fix: storageClassName: "" 👉 Key learning: Kubernetes matches PV & PVC based on: Storage capacity Access modes StorageClass (Not by name or path) 🧠 Reclaim Policy (Critical Concept) After cleanup: Dynamic PV → ❌ Auto-deleted (Delete) Static PV → ✅ Retained (Released) 👉 Important for: Data safety (Retain) Automation & cost efficiency (Delete) 📊 Key Takeaways ✔️ Containers are ephemeral ✔️ PVC abstracts storage ✔️ PV provides actual storage ✔️ Dynamic provisioning is default ✔️ Reclaim policies control data lifecycle 💻 GitHub Repo (Hands-on Implementation): https://lnkd.in/dQdrNNEd This was one of the most practical DevOps learnings so far — felt like working on real infrastructure 🔥 #Kubernetes #DevOps #CloudComputing #Containers #Docker #90DaysOfDevOps #DevOpsKaJosh #TrainWithShubhams

  • graphical user interface, text, application, chat or text message

To view or add a comment, sign in

Explore content categories