I have 2 microservices, one preparing a file and another reading it to handle HTTP requests. So I'm going to create a PVC and two deployments, one for each microservice. The deployment for the "writing" microservice will consist of a single pod, another deployment will be horizontally scalable. There are 3 access modes, but none of them seems to fit my needs perfectly, and the docs are not clear to me. So which PVC access mode should I choose? It's very desirable to be able to keep those pods on different nodes.
Asked
Active
Viewed 667 times
1
-
Can you provide more context and describe your goal with this? – acid_fuji Sep 10 '20 at 10:31
-
I have 2 microservices, one preparing a file and another reading it to handle HTTP requests. So I'm going to create a PVC and two deployments, one for each microservice. The deployment for the "writing" microservice will consist of a single pod, another deployment will be horizontally scalable. So which PVC access mode should I choose? – skozlov Sep 10 '20 at 10:53
-
Clarified the question. – skozlov Sep 14 '20 at 12:00
2 Answers
3
You need storage backend that supports ReadWriteMany
access modes and then set appropriate access mode for each deployment at the claim level (for pod that generates a file you would use ReadWriteOnce
and for the second deployment you would use ReadOnlyMany
mode).
So in order this to work you will have to use nfs
, cephfs
or other plugin that support ReadWriteMany
. More detailed plugin list can be found here.

acid_fuji
- 6,287
- 7
- 22
-
Thanks for the answer! I try it this Monday and, if it works, publish yaml. – skozlov Sep 10 '20 at 11:43
-
1It works. When the question is reopened, I publish the detailed solution. – skozlov Sep 14 '20 at 12:03
0
create 2 separate pvc with your desired access modes for the same pv and attach to pods based on their usage. e.g write many can be used for writing and readonly many can be used for the RO purpose. No pod will be able to access the volume unless the pvc is there.

Muhammad Hasan
- 140
- 1
- 9
-
3As far as I know, k8s doesn't allow creating multiple PVCs for a PV. https://stackoverflow.com/questions/44204223/kubernetes-nfs-persistent-volumes-multiple-claims-on-same-volume-claim-stuck – skozlov Sep 10 '20 at 10:30
-
1