In a cloud environment you’d typically have a proper load balancer in front of your Kubernetes cluster, such as Amazon ELB. In a bare-metal environment you don’t have this luxury, but setting up your own is rather easy.
The necessity for this is to reach the Kubernetes API on one common address, regardless of the health of your cluster. Should one node be down you’d still reach the cluster just fine, creating a proper high-availability configuration.
This setup is done on a fresh Fedora 32 VM, with access to the following Kubernetes cluster with the API running on port 6443 (default):
Make sure HAProxy can bind to any address and port:
Configure HAProxy to round-robin to these hosts, with health checks:
Open up the port in the firewall:
Then enable the HAProxy service:
And that’s it, you’re now load balancing the Kubernetes control plane.