0
0
Kubernetesdevops~30 mins

Why persistent storage matters in Kubernetes - See It in Action

Choose your learning style9 modes available
Why persistent storage matters in Kubernetes
📖 Scenario: You are managing a Kubernetes cluster that runs applications needing to save data permanently. You want to understand how to set up storage that keeps data safe even if containers restart or move.
🎯 Goal: Learn how to create a PersistentVolumeClaim in Kubernetes and use it in a Pod to keep data persistent across container restarts.
📋 What You'll Learn
Create a PersistentVolumeClaim named my-pvc requesting 1Gi of storage
Create a Pod named storage-demo that uses the my-pvc volume
Mount the volume inside the Pod at /data
Verify the Pod can write and read data from the persistent volume
💡 Why This Matters
🌍 Real World
Applications like databases, content management systems, and file servers need persistent storage to keep data safe even if containers restart or move to other nodes.
💼 Career
Understanding persistent storage in Kubernetes is crucial for DevOps engineers and cloud administrators to ensure data durability and application reliability.
Progress0 / 4 steps
1
Create a PersistentVolumeClaim
Write a YAML manifest to create a PersistentVolumeClaim named my-pvc that requests 1Gi of storage with access mode ReadWriteOnce.
Kubernetes
Need a hint?

Use kind: PersistentVolumeClaim and specify storage: 1Gi under resources.requests.

2
Create a Pod that uses the PersistentVolumeClaim
Write a YAML manifest to create a Pod named storage-demo that mounts the PersistentVolumeClaim my-pvc as a volume named mypvc-volume inside the container at path /data. Use the image busybox and keep the container running with sleep 3600.
Kubernetes
Need a hint?

Define a Pod with a container that mounts the volume from my-pvc at /data.

3
Write data inside the Pod to the persistent volume
Use kubectl exec to run the command echo 'Hello Kubernetes' > /data/message.txt inside the storage-demo Pod to write data to the persistent volume.
Kubernetes
Need a hint?

Use kubectl exec with sh -c to write the text into /data/message.txt.

4
Read the data back from the persistent volume
Use kubectl exec to run cat /data/message.txt inside the storage-demo Pod and print the output to verify the data is saved persistently.
Kubernetes
Need a hint?

Use kubectl exec storage-demo -- cat /data/message.txt to read and print the file content.