The one thing to understand first
Replication and automated failover handle the database side of high availability, but they are useless if clients keep connecting to a dead or demoted node. Connection routing is how applications always reach the current primary for writes (and optionally a standby for reads), and how that target switches atomically during failover. Getting this layer wrong reintroduces the split-brain and downtime that the cluster machinery worked to prevent.
The routing layer must derive “who is primary” from the same source of truth as failover — never an independent guess. A VIP, HAProxy, or pooler that picks the primary on its own can point clients at the wrong node and undo every split-brain protection beneath it.
Approach 1: Virtual IP (VIP)
A floating virtual IP is assigned to whichever node is currently primary. The application always connects to the VIP; during failover the orchestration moves the VIP to the new primary. Clients need no awareness of which physical node is the leader.