Interview Prep/Kubernetes/Configuration, Secrets and storage

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 →

  1. Container restart: data survives because the volume belongs to the pod
  2. Pod deleted or rescheduled: data is gone
  3. Verify with kubectl exec writing a file, killing the process, and reading again
  4. Use a PVC for durable data

Why → emptyDir lifetime equals pod lifetime.

Interview tip → Short and precise answers score well here.

All Kubernetes questions Roadmap: Kubernetes core

More on Configuration, Secrets and storage