Kubernetes 是否在主机上挂载了一个 emtpyDir 卷? [英] Does Kubernetes mount an emtpyDir volume on the host?

查看:26
本文介绍了Kubernetes 是否在主机上挂载了一个 emtpyDir 卷?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Kubernetes 具有多种类型的卷,包括 emptyDir:

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

emptyDir 卷在将 Pod 分配给节点时首先创建,并且只要该 Pod 在该节点上运行就存在.顾名思义,它最初是空的.Pod 中的容器都可以读取和写入 emptyDir 卷中的相同文件,尽管该卷可以安装在每个容器的相同或不同路径上.当 Pod 因任何原因从节点中删除时,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.

...

默认情况下,emptyDir 卷存储在支持节点的任何介质上.

emtpyDir 是否真的挂载在节点上,是否可以被 Pod 外的容器访问,或者节点 FS 本身可以访问?

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

推荐答案

是的,它也可以在节点上访问.它绑定安装到容器中(有点).源目录在/var/lib/kubelet/pods/PODUID/volumes/kubernetes.io~empty-dir/VOLUMENAME

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

这篇关于Kubernetes 是否在主机上挂载了一个 emtpyDir 卷?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆