Now we will install the load balancer that serves as the endpoint for connecting to API server. This will round-robin API server requests between each of the control plane nodes. For this we will use HAProxy in TCP load balancing mode. In this mode it simply forwards all traffic to its back ends (the control planes) without changing it e.g. doing SSL termination.
First, be logged into student-node
as directed above.
Log into the load balancer
ssh loadbalancer
Become root (saves typing sudo
before every command)
sudo -i
Update the apt package index and install packages needed for HAProxy:
apt-get update
apt-get install -y haproxy
Using the dig command which is an alternative to nslookup
and better for scripting with, we can get the private IP addresses of the loadbalancer and 3 control planes.
dig +short loadbalancer
dig +short controlplane01
dig +short controlplane02
dig +short controlplane03
Terminology
AWS EC2 instances effectively have two IP addresses:
Create the HAProxy configuration file
cat <<EOF > /etc/haproxy/haproxy.cfg
frontend kubernetes
bind $(dig +short loadbalancer):6443
option tcplog
mode tcp
default_backend kubernetes-control-nodes
backend kubernetes-control-nodes
mode tcp
balance roundrobin
option tcp-check
server controlplane01 $(dig +short controlplane01):6443 check fall 3 rise 2
server controlplane02 $(dig +short controlplane02):6443 check fall 3 rise 2
server controlplane03 $(dig +short controlplane03):6443 check fall 3 rise 2
EOF
Restart and check haproxy
systemctl restart haproxy
systemctl status haproxy
It should be warning us that no backend is available - which is true because we haven’t installed Kubernetes yet!
Exit from sudo
and then back to student-node
exit
exit
Next: Node Setup
Prev: Connectivity