Container and Volume Lifecycles · CKA
Distinguish what happens to data when a container restarts and when a Pod is deleted.
Learn with progress and quizzesFirst, understand the concepts.
emptyDir
An emptyDir is created when a Pod is assigned to a node and its data is removed when that Pod is removed from the node. Data survives container restarts within the same Pod.
Persistent volumes
PVs and PVCs let you manage storage lifecycles separately from Pods. Actual data retention depends on the reclaim policy and storage implementation.
Why it matters
Treating disposable cache and user uploads alike can lose important data during Pod replacement. Judge storage by what restarts and what is deleted.
Work through the reasoning
Compare lifetimes
A writable layer belongs to its container; emptyDir belongs to its Pod. Container restarts within that Pod retain emptyDir, but Pod replacement does not. PVC-backed data follows the separate volume lifecycle and policies.
Trace shared mounts
Match volumeMounts.name to volumes.name. Two containers can mount the same volume at different paths. Identical path strings alone do not imply shared storage.
Learn by doing.
You need kubectl and access to your own practice Kubernetes cluster. Each lab is independent. Check your current context first, then run the commands in your own terminal.
Look up volumes and volumeMounts in the Pod schema.
kubectl explain pod.spec.volumes
kubectl explain pod.spec.volumes.emptyDir
kubectl explain pod.spec.containers.volumeMountsHow to check your result
Explain the difference: volumes defines available volumes, while volumeMounts specifies where a container mounts them.
Apply what you learned
Where would you put temporary processing files and original user images? Explain whether they can be recreated after Pod replacement.
Reveal the reasoning after trying
Recomputable intermediate files can use emptyDir. Originals belong in durable storage or an object store with a separate backup and recovery plan. Having a PVC does not automatically provide backups.
Ready to check your understanding?
When is emptyDir data retained?
- After deleting and recreating the Pod
- When a container in the same Pod restarts
- When a new Pod is created on another node
- After deleting the namespace
Reveal the reasoning after trying
When a container in the same Pod restarts
The emptyDir lifecycle is tied to the Pod. Restarting a container within that Pod does not remove the volume.