Where Volume Data Lives
A Pod mounts five volumes, so where do their bytes live, and when does each one vanish? A write outside every volume lands in the container writable layer, emptyDir and hostPath sit on the Node storage, a Memory emptyDir sits in Node RAM, a ConfigMap is an API object that Kubelet copies in, and this claim points at network storage off the Node. Where the data lives decides whether it goes with the container, the Pod, the Node, or none of them.
Play the animation 7 steps, animated, best on a wide screen
Where Volume Data Lives, step by step
-
The app writes /tmp/report, a path no volume covers, so the bytes land in the writable layer of its own container. That layer sits on the Node storage, here its disk, but it belongs to that one container and to nothing else. It is the shortest lived home on this map.
Play from step 1 -
Three volumes keep their bytes on the Node. The emptyDir cache and the hostPath node-logs are directories on its storage, here its disk. The emptyDir scratch sets medium Memory, a tmpfs in Node RAM, and what it holds counts against the memory limit of the container that writes it.
Play from step 2 -
The config volume is a ConfigMap, an API object the API server stores in ETCD. Kubelet fetches it and writes each key into the Pod as a read-only file, so the app reads a copy. A Secret volume arrives the same way, into a tmpfs in RAM.
Play from step 3 -
The data volume is a PersistentVolumeClaim. Here the claim is bound to network storage, so its bytes live outside the Node entirely, reached over the network. Neither the Pod nor the Node owns that disk, and the data lasts at least as long as the claim that points at it.
Play from step 4 -
The app container crashes and Kubelet restarts it. The new container gets a fresh writable layer, so /tmp/report is gone and it starts clean. All five volumes are untouched, because none of them belonged to the container.
Play from step 5 -
Now the Pod is deleted. The emptyDir volumes cache and scratch are deleted with it, and the config files Kubelet wrote are removed. The ConfigMap object stays in the API server, the claim still holds its data, and node-logs stays on the Node disk.
Play from step 6 -
Finally the Node itself is lost, disk and all, and everything that lived on it goes too, node-logs included: a hostPath lasts only as long as that one Node disk. The ConfigMap and the claim data survive because they never lived on the Node. Where data lives decides how long it lives.
Play from step 7