I have a pod that needs to save data persistently to a place outside the pod. I think a persistentVolume is a good idea for that. The pod called writerPod needs ReadWrite-access to that volume.
Multiple other Pods (I'm calling them readingPods) need to read the files that writerPod saved.
Is it possible to have two persistentVolumeClaims (PVC) (that differ only in the accessMode ReadWriteOnce and ReadOnlyMany) that both bind the same PersistentVolume?
PVC can have more than one accessMode configured (both ReadOnlyMany and ReadWriteOnce):
accessModes:
- ReadWriteOnce
- ReadOnlyMany
However, as the names imply, you can mount the disk to many pods in ReadOnlyMany (AKA ROX
) but only one pod at a time can use that disk in ReadWriteOnce mode (AKA RWO
).
If your readingPods should be up only after your writerPod has written its data - you can use the same PVC, just make sure your mounting the PVC with the readOnly flag set to true, for example:
volumes:
- name: test-volume
persistentVolumeClaim:
claimName: my-pvc
readOnly: true
If you're using a Cloud provider that supports the ReadWriteMany access mode (Unfortunately, Google is not one of them right now) it will of-course suit you in all scenarios. Check the official documentation to check the supported modes on each platform.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With