I'm trying to run a basic highly available PostgreSQL cluster with Spilo-based images in Docker Swarm. Every few days, it starts failing in several ways: DNS resolution problems, connection timeouts, and corruption or inconsistency involving WAL data and etcd records. I can't currently afford a hosted database, so I'm hoping to find practical fixes or configuration advice from people who have operated this setup successfully. Kubernetes isn't a good fit for me right now because it would add too much operational complexity for this use case.
2 Answers
Another route would be running PostgreSQL with a Kubernetes operator such as CloudNativePG. It handles a lot of the replication, failover, and lifecycle details for you, but it does mean taking on Kubernetes, which may be more infrastructure than you want for this deployment.
I based a three-node cluster on Spilo's example configuration and haven't run into those failures. One important difference is that I avoided service DNS entirely and configured the nodes with fixed IP addresses through Ansible. That may help narrow down whether Swarm's DNS or service discovery is contributing to the instability.

Kubernetes feels like overkill for this setup, which is why I'm sticking with Docker Swarm for now. I'm mainly looking for a reliable Swarm-based configuration or a way to identify what's breaking.