10 months ago
Patroni is an open-source template for creating highly available PostgreSQL clusters. It manages automatic failover, leader election, and streaming replication using a distributed configuration store (DCS).
This bounty will be paid out when:
- A high-quality Patroni Railway template is presented
- All potential template feedback has been incorporated
- All requirements are met and tested
Template Requirements
- Multi-service deployment including Multiple PostgreSQL/Patroni nodes (2-3 nodes), a distributed configuration store (etcd cluster recommended), and a connection pooler/load balancer (HAProxy or PgPool)
- Volume-backed storage for PostgreSQL data directories to preserve data across redeploys
- Volume-backed storage for the DCS (etcd) data directory to maintain cluster state
- Service dependencies should be correctly configured with proper startup order and health checks between the DCS, Patroni/PostgreSQL nodes, and load balancer
- Environment variables properly configured for Railway domains; internal services should use the private network (
.railway.internal) to communicate - Load balancer should be configured to route write traffic to the primary node and optionally load-balance read traffic across replicas
- Template should expose the load balancer endpoint for users to connect their applications to the PostgreSQL cluster
Some Additional Context
This one's a complex deployment, some challenges to think about:
- Private Networking: Railway now supports IPv4 private networking which should help simplify etcd configuration (compared to IPv6-only networking)
- etcd Cluster Bootstrap: etcd requires all members to successfully start for initial bootstrap. Consider using etcd's discovery service or DNS-based discovery rather than hardcoded IPs, since container addresses can change on redeploy
- Startup Ordering: The DCS (etcd) must be healthy before Patroni nodes can initialize. Patroni nodes need proper retry/wait logic or health check dependencies.
Highly encourage contributors to use this thread to chat about any issues you might run into 🤝
A few resources to get you started:
13 Replies
samgordon
Am almost done with this one
10 months ago
dang was just going to get started 😅 looking forward to seeing what you've come up with 🤝
10 months ago
I just cannot get ETCD to connect over the private network with IPv6 or 4. I have pretty much everything else working. Railway seems to keep resolving to IPv6.
10 months ago
Finally made a breakthrough with ETCD, fixing another issue and then we're finally done
10 months ago
Is there any way to force my service to use IPv4 or 6? Part of the service uses a linux command on the domain which then resolves to both an IPv6 and a 4 domain, and it breaks Patroni.
10 months ago
This is what the template looks like right now. It's all "running" but Patroni really doesn't live dualstack.
Attachments
10 months ago
The error I'm getting is very silly... but it has to be inside the code.
Attachments
10 months ago
Found the root cause... I'm going to have to modify their startup command but I should be able to do it dynamically with a sed command.
10 months ago
https://railway.com/deploy/patroni
This took me an EXTREMELY long time. But here it is. Have at thee.
9 months ago
I am working on this
9 months ago
Going to close this out as we will be developing something for this internally.
Status changed to Closed brody • 9 months ago

