我需要一个可从多个 pod 访问的共享卷,以便在每个节点的 RAM 中缓存文件。
问题是 emptyDir
volume provisioner(支持 Memory
作为其 medium
)在 Volume
中可用> 规范,但不在 PersistentVolume
规范中。
除了通过在每个主机上手动创建一个 tmpfs
卷并通过 local
或 hostPath
provisioner 挂载它之外,有什么方法可以实现这一点在 PV 规范中?
注意 Docker 本身支持这样的卷:
docker volume create --driver local --opt type=tmpfs --opt device=tmpfs \
--opt o=size=100m,uid=1000 foo
我看不出 k8s 没有的任何理由。或者可能确实如此,但并不明显?
我尝试使用 local
和 hostPath
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/