Search code examples
kubernetesrace-conditionkubernetes-podpersistent-volumesamazon-eks

How to share an EBS volume between 2 or more pods (only one will write, and the rest will only read)?


I understand that EBS volumes are currently only ReadWriteOnce.

However, I have been able to have a persistent volume shared between two or more pods, if those pods get started almost at the same time. One of them writes to the volumes, and the other one(s) only reads some files.

This approach has not been successful all time: It seems that if for any reason the read-only pod gets created ahead of the main pod, the main pod would get indefinitely stuck at ContainerCreating status with Multi-Attach error for volume ... warning.

Any advise? Thanks.


Solution

  • One solution that I have successfully tried was to add an initContainers to the read-only pods with a long sleep command there to make sure they do not get created before the main pod.