Managing a Patroni cluster is relatively easy as long as it's operating normally. The primary reason for this is the provided patronictl command-line tool. Beyond simply displaying the cluster status, it also manages several other helpful operations.
In particular, we can use it to force the primary node to step down and allow one of the replicas to take its place. In a high-availability context, this is a great way to perform system upgrades. We merely need to switch to another primary, upgrade the old system, and repeat. We're done when every node is the latest PostgreSQL version. During this process, the database is never offline. This procedure also works for regular system maintenance.
This recipe will demonstrate the process to change the primary node using Patroni.