I need a shared volume accessible from multiple pods for caching files in RAM on each node.
The problem is that the emptyDir
volume provisioner (which supports Memory
as its medium
) is available in Volume
spec but not in PersistentVolume
spec.
Is there any way to achieve this, except by creating a tmpfs
volume manually on each host and mounting it via local
or hostPath
provisioner in the PV spec?
Note that Docker itself supports such volumes:
docker volume create --driver local --opt type=tmpfs --opt device=tmpfs \
--opt o=size=100m,uid=1000 foo
I don't see any reason why k8s doesn't. Or maybe it does, but it's not obvious?
I tried playing with local
and hostPath
PVs with mountOptions
but it didn't work.
EmtpyDir tied to lifetime of a pod, so it can't be used via shared with multiple pods. What you request, is additional feature and if you look at below github discussions, you will see that you are not the first that asking for this feature.
consider a tmpfs storage class
Also according your mention that docker supports this tmpfs volume
, yes it supports, but you can't share this volume between containers. From Documentation
Limitations of tmpfs mounts:
Unlike volumes and bind mounts, you can’t share tmpfs mounts between containers.