Kubernetes - Control Plane

Last Updated: 2022-10-09

HAProxy and Keepalived

  • haproxy: load balance HTTP requests.
  • keepalived: keepalived makes haproxy highly available; an implementation of VRRP.

Virtual IP

ip will appear in ip a s if the node is alive, otherwise will disappear (can be simulated by systemctl stop haproxy) and the vip will appear in another configured node.


In the event that the master server (haproxy1) fails, keepalived assigns the virtual IP address (e.g. to the eth0 interface on the backup server (haproxy2), which becomes the master server.

The active (master) router informs the backup routers of its active status using the Virtual Router Redundancy Protocol (VRRP), which requires the master router to send out advertisements at regular intervals. If the active router stops sending advertisements, a new master is elected.

Keepalived implements Virtual Router Redundancy Protocol, also known as VRRP. Usually, the VRRP protocol ensures that only one of the participating instances is running as MASTER. The other instances are in the BACKUP state listening for multicast packets from an instance with a higher priority.

If the BACKUP instance fails to receive VRRP advertisements for a period longer than the KEEPALIVED_ADVERT_INT, the BACKUP instance moves to the MASTER state and it takes the VIP for itself. In case there is more than one instance in BA

A VIP address migrates from one LVS router to the other during a failover, thus maintaining a presence at that IP address. A VIP is also known as a floating IP addresses.


haproxy and keepalived can be containerized or non-containerized.

If non-containerized:

Configs can be found in /etc folder:


They are managed by systemctl

systemctl restart haproxy
systemctl enable haproxy
systemctl restart keepalived
systemctl enable keepalived

If containerized:

Check keepalived config:

kubectl -n kube-system exec kube-keepalived-master -- cat /etc/keepalived/keepalived.conf