Interview Prep/Kubernetes/Configuration, Secrets and storage

What is the difference between emptyDir, hostPath, PV/PVC and when do you use each?

BeginnerScenarioConfiguration, Secrets and storage
Answer

Situation read → A developer wants scratch space and persistent storage.

What I'd do →

  1. emptyDir for scratch data shared across containers in a pod, lost with the pod
  2. hostPath mounts a node directory; avoid it except for node agents
  3. PVC through a StorageClass for durable data
  4. For memory-backed scratch use emptyDir.medium: Memory with a sizeLimit
  5. Choose by durability and portability needs

Why → Storage lifetime differs: pod, node, or independent of both.

Interview tip → Mention hostPath as a security risk and a PSA baseline violation.

All Kubernetes questions Roadmap: Kubernetes core

More on Configuration, Secrets and storage