<p>We currently have a 2-node Kubernetes environment running on bare-metal machines (no GCE) and now we wish to set up a PostgreSQL instance on top of this.</p>

<p>Our plan was to map a data volume for the PostgreSQL Data Directory to the node using the <code>volumeMounts</code> option in Kubernetes.  However this would be a problem because if the Pod ever gets stopped, Kubernetes will re-launch it at random on one of the other nodes. Thus we have no guarantee that it will use the correct data directory on re-launch...</p>

<p>So what is the best approach for maintaining a consistent and persistent PostgreSQL Data Directory across a Kubernetes cluster?</p>

<ul>
<li><p>one solution is to deploy HA postgresql, for example <a href="https://github.com/sorintlab/stolon" rel="nofollow">https://github.com/sorintlab/stolon</a></p></li>
<li><p>another is to have some network storage attached to all nodes(NFS, glusterFS) and use volumeMounts in the pods</p></li>
</ul>
