0
0
Kubernetesdevops~10 mins

Volumes vs Persistent Volumes in Kubernetes - Visual Side-by-Side Comparison

Choose your learning style9 modes available
Process Flow - Volumes vs Persistent Volumes
Pod starts
Volume attached
Data stored temporarily
Pod stops -> Volume lost
Persistent Volume created
Pod claims Persistent Volume
Data stored persistently
Pod stops -> Data remains intact
Shows how normal Volumes exist only during pod life, while Persistent Volumes keep data beyond pod life.
Execution Sample
Kubernetes
apiVersion: v1
kind: Pod
metadata:
  name: example-pod
spec:
  volumes:
  - name: temp-volume
    emptyDir: {}
  containers:
  - name: app
    image: busybox
    volumeMounts:
    - mountPath: /data
      name: temp-volume
Defines a pod with a temporary volume (emptyDir) that lasts only while the pod runs.
Process Table
StepActionVolume TypeData PersistenceResult
1Pod startsemptyDir VolumeData stored temporarilyVolume created and mounted to pod
2Write data inside pod at /dataemptyDir VolumeData available during pod lifeData written successfully
3Pod stopsemptyDir VolumeData lost after pod stopsVolume deleted, data lost
4PersistentVolume created by adminPersistent VolumeData stored persistentlyVolume ready for claim
5Pod claims PersistentVolume via PersistentVolumeClaimPersistent VolumeData persists beyond pod lifeVolume mounted to pod
6Write data inside pod at mounted pathPersistent VolumeData saved persistentlyData written successfully
7Pod stopsPersistent VolumeData remains intactVolume still exists with data
💡 Pod lifecycle ends; emptyDir volume data lost, Persistent Volume data remains.
Status Tracker
VariableStartAfter Step 2After Step 3After Step 6After Step 7
emptyDir Volume Datanonedata presentlost (none)n/an/a
Persistent Volume Datanonen/an/adata presentdata present
Key Moments - 3 Insights
Why does data in emptyDir volume disappear after pod stops?
Because emptyDir volumes exist only during pod life, as shown in execution_table step 3 where pod stops and data is lost.
How does Persistent Volume keep data after pod stops?
Persistent Volumes are independent resources that exist beyond pod lifecycle, shown in steps 4-7 where data remains after pod stops.
Can multiple pods share the same Persistent Volume?
Yes, Persistent Volumes can be shared if configured, unlike emptyDir which is pod-specific. This is implied by Persistent Volume being separate from pod lifecycle.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what happens to data in emptyDir volume at step 3?
AData is lost because pod stops
BData is saved permanently
CData is copied to Persistent Volume
DData is backed up automatically
💡 Hint
Check execution_table row for step 3 under 'Result' and 'Data Persistence'
At which step does the pod claim a Persistent Volume?
AStep 2
BStep 5
CStep 1
DStep 7
💡 Hint
Look at execution_table 'Action' column for pod claiming Persistent Volume
If the pod using emptyDir volume restarts, what happens to the data?
AData is moved to Persistent Volume automatically
BData remains intact after restart
CData is lost and volume is recreated
DPod cannot restart with emptyDir volume
💡 Hint
Refer to variable_tracker for emptyDir Volume Data after pod stops (step 3)
Concept Snapshot
Volumes in Kubernetes are temporary storage tied to pod life (e.g., emptyDir).
Persistent Volumes are independent storage resources that keep data beyond pod lifecycle.
Pods use PersistentVolumeClaims to access Persistent Volumes.
emptyDir data is lost when pod stops; Persistent Volume data remains.
Use Persistent Volumes for important data needing durability.
Full Transcript
This visual execution compares Kubernetes Volumes and Persistent Volumes. When a pod starts, it can use a Volume like emptyDir which stores data temporarily. Data written to emptyDir is lost when the pod stops, as shown in step 3 of the execution table. In contrast, Persistent Volumes are created separately and exist beyond pod life. Pods claim Persistent Volumes via PersistentVolumeClaims, mount them, and write data that persists even after the pod stops, demonstrated in steps 4 to 7. The variable tracker shows emptyDir data disappears after pod stops, while Persistent Volume data remains. Key moments clarify why emptyDir data is lost and how Persistent Volumes provide durable storage. The quiz tests understanding of these lifecycle differences and data persistence behaviors.