Skip to main content

OKD - Create a Homelab Cluster - HAProxy

We'll be working on the Servers that are surrounded by the continous lines in this drawing:

In this part I'll cover the HAProxy setup on each helper node. Haproxy is a TCP / HTTP Load Balancer which I'll be use to proxy traffic for the following Services:

  • Kubernetes API Server (6443/tcp)
  • OpenShift Machine Config Server (22623/tcp)
  • HTTP Ingress (80/tcp)
  • HTTPS Ingress (443/tcp)
  • HAProxy Stats (9000/tcp)
Make sure to have no other services running on any of these ports. These steps will apply to all helper nodes, so you can just copy and paste these steps for each helper node.

First, install HAProxy:
 [archy@helper01 ~]$ sudo dnf -4y --refresh install haproxy  
Now, edit /etc/haproxy/haproxy.cfg according to your environment:
 [archy@helper01 ~]$ sudo vim /etc/haproxy/haproxy.cfg  

 global  
   log 127.0.0.1 local2  
   pidfile /var/run/haproxy.pid  
   maxconn 4000  
   daemon  
 defaults  
   mode http  
   log global  
   option dontlognull  
   option http-server-close  
   option redispatch  
   retries 3  
   timeout http-request 10s  
   timeout queue 1m  
   timeout connect 10s  
   timeout client 1m  
   timeout server 1m  
   timeout http-keep-alive 10s  
   timeout check 10s  
   maxconn 3000  
 frontend stats  
   bind 0.0.0.0:9000  
   mode http  
   log global  
   maxconn 10  
   stats enable  
   stats hide-version  
   stats refresh 30s  
   stats show-node  
   stats show-desc Stats for ha service  
   stats uri /stats  
 listen api-server-6443  
   bind 0.0.0.0:6443  
   mode tcp  
   server bootstrap bootstrap.okd.archyslife.lan:6443 check inter 1s  
   server master01 master01.okd.archyslife.lan:6443 check inter 1s  
   server master02 master02.okd.archyslife.lan:6443 check inter 1s  
   server master03 master03.okd.archyslife.lan:6443 check inter 1s  
 listen machine-config-server-22623  
   bind 0.0.0.0:22623  
   mode tcp  
   server bootstrap bootstrap.okd.archyslife.lan:22623 check inter 1s  
   server master01 master01.okd.archyslife.lan:22623 check inter 1s  
   server master02 master02.okd.archyslife.lan:22623 check inter 1s  
   server master03 master03.okd.archyslife.lan:22623 check inter 1s  
 listen http-ingress-80  
   bind 0.0.0.0:80  
   mode tcp  
   server worker01 worker01.okd.archyslife.lan:80 check inter 1s  
   server worker02 worker02.okd.archyslife.lan:80 check inter 1s  
 listen https-ingress-443  
   bind 0.0.0.0:443  
   mode tcp  
   server worker01 worker01.okd.archyslife.lan:443 check inter 1s  
   server worker02 worker02.okd.archyslife.lan:443 check inter 1s  
Set the SELinux boolean 'haproxy_can_connect_any' to true:
 [archy@helper01 ~]$ sudo setsebool -P haproxy_connect_any 1  
Now restart and enable the haproxy service:
 [archy@helper01 ~]$ sudo systemctl enable --now haproxy.service  
The haproxy stats page is available on Port 9000 using the '/stats' url. In my case, it's 'http://helper01.okd.archyslife.lan:9000/stats' for the first node.

Feel free to comment and / or suggest a topic.

Comments