DrGecko
DrGecko

Reputation: 889

Kubernetes - Persistent storage for PostgreSQL

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.

Our plan was to map a data volume for the PostgreSQL Data Directory to the node using the volumeMounts 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...

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

Upvotes: 3

Views: 1803

Answers (1)

lwolf
lwolf

Reputation: 980

  • one solution is to deploy HA postgresql, for example https://github.com/sorintlab/stolon

  • another is to have some network storage attached to all nodes(NFS, glusterFS) and use volumeMounts in the pods

Upvotes: 1

Related Questions