Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Kubernetes mount an emtpyDir volume on the host?

Tags:

kubernetes

Kubernetes features quite a few types of volumes, including emptyDir:

An emptyDir volume is first created when a Pod is assigned to a Node, and exists as long as that Pod is running on that node. As the name says, it is initially empty. Containers in the pod can all read and write the same files in the emptyDir volume, though that volume can be mounted at the same or different paths in each container. When a Pod is removed from a node for any reason, the data in the emptyDir is deleted forever.

...

By default, emptyDir volumes are stored on whatever medium is backing the node.

Is the emtpyDir actually mounted on the node, and accessible to a container outside the pod, or to the node FS itself?

like image 288
Adam Matan Avatar asked Oct 02 '17 12:10

Adam Matan


1 Answers

Yes it is also accessible on the node. It is bind mounted into the container (sort of). The source directories are under /var/lib/kubelet/pods/PODUID/volumes/kubernetes.io~empty-dir/VOLUMENAME

You can find the location on the host like this:

sudo ls -l /var/lib/kubelet/pods/`kubectl get pod -n mynamespace mypod -o 'jsonpath={.metadata.uid}'`/volumes/kubernetes.io~empty-dir
like image 74
Janos Lenart Avatar answered Nov 20 '22 21:11

Janos Lenart