Implementing leader election
Leader election is an important concept in any distributed computing system, not just Kubernetes (and not just for Operators, either). High-availability applications will often deploy multiple replicas of their workload Pods to support the uptime guarantees their users expect. In situations where only one workload Pod can do work in a cluster at a time, that replica is known as the leader. The remaining replicas will wait, running but not doing anything significant, until the current leader becomes unavailable or gives up its status as the leader. Those Pods will then determine among themselves who should be the new leader.
Enabling proper leader election can greatly benefit the application's uptime. This can include graceful failover handling if one replica fails, or help to maintain application accessibility during rolling upgrades.
The Operator SDK makes leader election for Operators simple to implement. The boilerplate code scaffolded by...