Skip to content
tezvyn:

What happens to volume data when a Pod is deleted?

Source: interviewEasyHow cards are made

Summary

volume lifecycle awareness.

Key points

emptyDir is tied to the Pod and erased when the Pod is deleted; a PVC-backed PV with Retain keeps the data after the PVC is released for manual recovery.

What's really being asked

Whether you can distinguish ephemeral, Pod-scoped storage from durable, cluster-scoped storage, and whether you know what reclaim policies actually do.

The full answer

An emptyDir volume is created when a Pod is scheduled to a node and exists only for that Pod's lifetime. It survives container restarts within the Pod, but when the Pod is deleted or rescheduled to another node, the emptyDir and all its contents are erased. It is meant for scratch space, caches, or sharing files between containers in the same Pod. A PersistentVolumeClaim backed by a PersistentVolume is different: the data lives on storage whose lifecycle is independent of the Pod. With the Retain reclaim policy, deleting the PVC does not delete the data. The bound PV transitions to the Released state, the external storage asset and its data remain intact, and an administrator can manually recover or re-provision it. Retain explicitly does not auto-rebind or auto-delete, unlike the Delete policy, which removes the backing storage.

The mistakes people make

Thinking emptyDir persists across Pod deletion or node moves. Believing Retain makes the volume automatically reusable by a new PVC. Confusing Retain with Recycle, which is deprecated. Assuming all PVCs delete their data when released.

What usually comes next

How do the Delete and the deprecated Recycle policies differ from Retain? When would you choose emptyDir with memory medium? How do you reclaim a Released PV for reuse?

A concrete example

A Pod uses emptyDir for a build cache; deleting the Pod wipes the cache. A database Pod uses a PVC bound to a Retain PV; deleting the PVC leaves the EBS volume and its data intact in Released state so an operator can attach it to a new claim after manual cleanup.

Interview question

A Pod with an emptyDir and a Retain PVC is deleted. What is the outcome for each volume's data?

  • a.Both are erased immediately
  • b.emptyDir persists; the Retain PV is deleted
  • c.emptyDir data is erased; the Retain PV's data persists in Released stateCorrect
  • d.Both survive and are automatically remounted
Why?

emptyDir lives only for the Pod's lifetime, so it is erased on deletion, while a Retain PV keeps its data and moves to Released for manual recovery. Retain does not auto-remount, and the PV's data is not deleted.

Just read this? Test yourself on what you have been reading.

Read the original → kubernetes.io

Put your scrolling time to good use

Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Open roles that interview on kubernetes — each one lists the topics its interview covers.

See open roles