linux - Kubernetes:在 pod 之间共享内存卷

标签 linux docker kubernetes tmpfs

我需要一个可从多个 pod 访问的共享卷,以便在每个节点的 RAM 中缓存文件。

问题是 emptyDir volume provisioner(支持 Memory 作为其 medium)在 Volume 中可用> 规范,但不在 PersistentVolume 规范中。

除了通过在每个主机上手动创建一个 tmpfs 卷并通过 localhostPath provisioner 挂载它之外,有什么方法可以实现这一点在 PV 规范中?

注意 Docker 本身支持这样的卷:

docker volume create --driver local --opt type=tmpfs --opt device=tmpfs \
       --opt o=size=100m,uid=1000 foo

我看不出 k8s 没有的任何理由。或者可能确实如此,但并不明显?

我尝试使用 localhostPath PV 和 mountOptions 但它没有用。

最佳答案

EmtpyDir 与 pod 的生命周期相关,因此不能通过与多个 pod 共享来使用。 您请求的是附加功能,如果您查看下面的 github 讨论,您会发现您不是第一个要求此功能的人。

consider a tmpfs storage class

此外,根据您提到的 docker 支持此 tmpfs 卷,是的,它支持,但您不能在容器之间共享此卷。来自 Documentation

Limitations of tmpfs mounts:

Unlike volumes and bind mounts, you can’t share tmpfs mounts between containers.

关于linux - Kubernetes:在 pod 之间共享内存卷,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55093983/

相关文章:

linux - Rancher -standard_init_linux.go :190: exec user process caused "permission denied"

c++ - 为什么 linux 在分配动态内存时会占用一些额外的空间?

c - 使用C语言进行Linux网络编程

python - 如何解决 UnicodeDecodeError, invalid continuation byte 错误

node.js - 启动应用失败

google-cloud-platform - 在开发机器中安装kubernetes的卷

kubernetes - 如何将 Kubernetes 与 IBM bluemix 容器一起使用

tomcat - 如何解决ehcache同类的classcastexception

asp.net - Windows 容器中的容器文件权限

kubernetes - 未考虑重新分配的Istio等级限制