<p>I want to store the data from a PostgreSQL database in a <code>persistentvolumeclaim</code>.
(on a managed Kubernetes cluster on Microsoft Azure)</p>
<p><strong>And I am not sure which access mode to choose.</strong></p>
<p>Looking at the available <a href="https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes" rel="nofollow noreferrer">access modes</a>:</p>
<ul>
<li><code>ReadWriteOnce</code></li>
<li><code>ReadOnlyMany</code></li>
<li><code>ReadWriteMany</code></li>
<li><code>ReadWriteOncePod</code></li>
</ul>
<p>I would say, I should choose either <code>ReadWriteOnce</code> or <code>ReadWriteMany</code>.</p>
<p>Thinking about the fact that I might want to migrate the database pod to another node pool at some point, I would intuitively choose <code>ReadWriteMany</code>.</p>
<p>Is there any disadvantage if I choose <code>ReadWriteMany</code> instead of <code>ReadWriteOnce</code>?</p>

zingi
<p>You are correct with the migration, where the access mode should be set to <code>ReadWriteMany</code>.</p>
<p>Generally, if you have access mode <code>ReadWriteOnce</code> 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 <code>DaemonSet</code> where one pod is scheduled on each node, this could pose a problem. In this scenario, you are best with tagging the <code>PVC</code> and <code>PV</code> with access mode <code>ReadWriteMany</code>.</p>
<p>Therefore</p>
<ul>
<li>if you want multiple pods to be scheduled on multiple nodes and have access to DB, for write and read permissions, use access mode <code>ReadWriteMany</code></li>
<li>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 <code>ReadWriteOnce</code></li>
</ul>
