I want to store the data from a PostgreSQL database in a persistentvolumeclaim
.
(on a managed Kubernetes cluster on Microsoft Azure)
And I am not sure which access mode to choose.
Looking at the available access modes:
ReadWriteOnce
ReadOnlyMany
ReadWriteMany
ReadWriteOncePod
I would say, I should choose either ReadWriteOnce
or ReadWriteMany
.
Thinking about the fact that I might want to migrate the database pod to another node pool at some point, I would intuitively choose ReadWriteMany
.
Is there any disadvantage if I choose ReadWriteMany
instead of ReadWriteOnce
?
CodePudding user response:
You are correct with the migration, where the access mode should be set to ReadWriteMany
.
Generally, if you have access mode ReadWriteOnce
and a multinode cluster on microsoft azure, where multiple pods need to access the database, then the kubernetes will enforce all the pods to be scheduled on the node that mounts the volume first. Your node can be overloaded with pods. Now, if you have a DaemonSet
where one pod is scheduled on each node, this could pose a problem. In this scenario, you are best with tagging the PVC
and PV
with access mode ReadWriteMany
.
Therefore
- if you want multiple pods to be scheduled on multiple nodes and have access to DB, for write and read permissions, use access mode
ReadWriteMany
- if you logically need to have pods/db on one node and know for sure, that you will keep the logic on the one node, use access mode
ReadWriteOnce