Using Avi to load balance multiple Kubernetes or OpenShift masters

When setting up high-availability Kubernetes or OpenShift masters, a load balancer needs to be created with the individual master IPs in the load balancing pool. This is done so that the kubelets can direct all management traffic to the cluster VIP, instead of trying to keep an up-to-date list of the API server. When using Avi as an ADC for Kubernetes or OpenShift environment, it can also be used to load balance the master nodes. This article walks you through the steps involved in creating a VS to load balance multiple master nodes of a Kubernetes or OpenShift HA cluster.

  • The cluster VIP needs to be external to the Kubernetes/OpenShift environment. For this, create a new cloud (InfraCloud). This can be of any type and leverage the IaaS on which the Kubernetes/OpenShift cluster is created. For example here the cluster was created on VMs in a vCenter environment so we create a new cloud of VMware vCenter type.

    Cloud

  • Create new virtual service, select ‘Advanced Setup’ and choose the InfraCloud

    Select_cloud

  • Configure a L4 TCP virtual service as shown:

    VS_create

    Note: Configure the IP and port you want the API clients to use. In this example we are setting it to 10.0.0.1:443

  • Configure the pool as shown:

    Config_pool

    Note: Check your kubernetes/OpenShift config for correct port number for the api server. The example above shows port 8443

  • ” Add the master node IP addresses to the pool

    Add_servers

  • The resulting VS should look as shown: :

    Tree_view

The VIP of this virtual service can be used as the API server IP for the Kubernetes/OpenShift cluster. You can add this https://VIP:port to kubeconfig so that kubectl uses the virtual service to reach the API server.

The Avi kubernetes cloud can also be configured using this VIP as master URL, instead of adding the master nodes individually.