Server administration

Adding HAProxy as load balancer to the Kubernetes cluster

0 min read

As I mentioned in my Kubernetes homelab setup post, I initially setup Kemp Free load balancer as an easy quick solution.While Kemp did me good, I’ve had experience playing with HAProxy and figured it could be a good alternative to the extensive options Kemp offers. It could also be a good start if I wanted to have HAProxy as an ingress in my cluster at some point.

There’s a few things here we need in order to make this work:

1 – Make HAProxy load balance on 6443
2- Make HAProxy health check our nodes on the /healthz path

Configuring HAProxy

Since I’m using debian 10 (buster), I will install HAProxy using apt install haproxy -y

Next step is to configure HAProxy. Its configuration file lives in /etc/haproxy/haproxy.cfg. Here’s my configuration file. Adapt it to your needs.

Once configured and running, the dashboard should mark all the master nodes up, green and running

HAProxy dashboard stats