Ingress and Failover

The way we have it working is to set up a pair of VMs outside of the Kubernetes cluster running Keepalived and HAproxy. Keepalived makes sure that a single (or multiple) VIP is only running on a single host. It also handles the failover to the second host in case that frontend host goes down.

The HAProxy config has a frontend that binds to the VIP, and the backend points to each host in the Kubernetes cluster. Your DNS entries for all of your services are CNAME entries pointing to the VIP. When one of the compute nodes goes down, the HAProxy health checks see it is not there, and take it out of the backend pool so all requests go to the remaining host(s) until the host comes back up.

It’s not a self-contained solution inside of Kubernetes, but thanks to the way the Ingress works, you can have all of your services mapped to a single VIP and the Ingress routes to the proper service based on the hostname of the request. Once you have the HAproxy/Keepalived set up, you don’t ever have to touch it unless you add another cluster, or add another Kubernetes cluster host.

1 Like