Sobes.tech
Middle+

How to set up a floating IP through Patroni so that the client does not know which node it will connect to?

sobes.tech AI

Answer from AI

Patroni itself does not manage the floating IP, but it can be configured together with tools for managing virtual IPs, such as using keepalived or pacemaker.

The idea is that during a failover, the floating IP is transferred to the new master, and clients always connect to the same IP, without knowing which node they are actually connected to.

An example configuration with keepalived:

  1. Configure keepalived on all Patroni nodes to monitor the PostgreSQL service status.
  2. When a node becomes the master, keepalived activates the floating IP on that node.
  3. During role switches, the IP is transferred to the new master.

This allows clients to connect using a single IP, and Patroni and keepalived ensure that this IP always points to the current master.