Is there a way to share files among pods without persistence?
With persistence I just use
accessMode and mount it to somewhere:
apiVersion: v1 kind: PersistentVolumeClaim metadata: name: my-pvc spec: accessModes: - ReadWriteMany storageClassName: some-sc resources: requests: storage: 1Gi
I need to do something like this without PVC or with PVC that uses a storage-class which just mimic persistence by using only the memory.
I could solve this with a different pod which redistributes the file by using K8s api.<br> But I feel it a bit overwhelming for a simple task like that.
configmap is out of question because the file should be writable.
Posted community wiki for better visibility with a general solution as there are no further details provided. Feel free to expand it.
As @DavidMaze mentioned in his comment:
I don't think there's really a way to do this (how would the pods know what to mount without the PVC declaration? How would they share memory if they're on different nodes?)
There is no such possibility in Kubernetes to share files among pods without persistence.
If you want to share storage between containers in the same pods you can take a look into emptyDir volume. It can use memory (tmpfs) system:
Depending on your environment,
emptyDirvolumes are stored on whatever medium that backs the node such as disk or SSD, or network storage. However, if you set the
"Memory", Kubernetes mounts a tmpfs (RAM-backed filesystem) for you instead. While tmpfs is very fast, be aware that, unlike disks, tmpfs is cleared on node reboot and any files you write count against your container's memory limit.
As @DavidMaze mentioned in his comment, if your app is capable of passing the content over HTTP you can use a message queue:
Can your application pass the content over HTTP, or use a message queue like RabbitMQ, instead of relying on a filesystem?
Check also this topic with different answers/solutions about sharing storage between pods (but with persistence).