What happens to data in an emptyDir when a container crashes versus when the pod is deleted?
BeginnerScenarioConfiguration, Secrets and storage
Answer
Situation read → A teammate expects emptyDir data to survive restarts.
What I'd do →
- Container restart: data survives because the volume belongs to the pod
- Pod deleted or rescheduled: data is gone
- Verify with
kubectl execwriting a file, killing the process, and reading again - Use a PVC for durable data
Why → emptyDir lifetime equals pod lifetime.
Interview tip → Short and precise answers score well here.
More on Configuration, Secrets and storage
How do you inject configuration into pods and what are the options?BeginnerA ConfigMap was updated but the pod still shows old values. Why?IntermediateHow do you store a database password safely in Kubernetes?BeginnerHow do you manage secrets in GitOps without committing them in plain text?IntermediateA pod fails with `CreateContainerConfigError` and a missing key. What happened?BeginnerWhat is the difference between emptyDir, hostPath, PV/PVC and when do you use each?Beginner