vitabaks / postgresql_cluster

PostgreSQL High-Availability Cluster (based on "Patroni" and DCS "etcd" or "consul"). Automating with Ansible.
MIT License
1.27k stars 340 forks source link

Add Patroni REST API endpoint configuration and custom tag support #586

Closed vitabaks closed 1 month ago

vitabaks commented 2 months ago

I am currently working on a PostgreSQL cluster setup that spans across multiple data centers. We use a setup with HAProxy load balancers in each data center to manage local and cross-data center traffic. Our goal is to optimize traffic within local data centers while maintaining failover capabilities between them.

To better support our multi-data center setup, we are looking into enhancing our automation to provide more granular control over database endpoint configurations and load balancing. Specifically, we are interested in:

  1. Endpoint Configuration in Patroni REST API: We need the automation to support custom configurations for Patroni REST API endpoints. This is crucial for defining different behaviors based on the data center context, such as directing read traffic primarily within the same data center.

  2. Custom Tag Support for Load Balancing: We would like to introduce the capability to add custom tags in the endpoint configurations. For example, by adding datacenter=<name> or region=<name> to the endpoint configuration, we could ensure that load balancing is only considering replicas within the same local data center, thereby excluding servers from a remote data center or region.

This feature would address scenarios where a multi-data center setup starts from one location and expands, allowing for a more flexible and efficient database management strategy across different geographical locations.

The desired outcome is to allow for configuration like the following in the automation setup:

Documentation: https://patroni.readthedocs.io/en/latest/rest_api.html#health-check-endpoints

This enhancement would significantly improve our database management's efficiency and flexibility across multiple data centers, ensuring better performance and failover support.


Consider sponsoring the project via GitHub or Patreon