Installing MetalLB load balancers
This page lists the installation and configuration instructions for the MetalLB managed load balancer.
Installing The MetalLB Load Balancer
The MetalLB load balancer is fully integrated with Anthos Clusters on VMware and has automated deployment performed as part of the Admin and User cluster setups starting with the 1.11 release. There are blocks of text in the respective cluster.yaml
configuration files that you must modify to provide load balancer info. It is self-hosted on your Anthos cluster instead of requiring the deployment of external resources like the other supported load balancer solutions. It also allows you to create an ip-pool that automatically assigns addresses with the creation of Kubernetes services of type load balancer in clusters that do not run on a cloud provider.
Integration with Anthos
When enabling the MetalLB load balancer for Anthos admin, you must modify a few lines in the loadBalancer:
section that exists in the admin-cluster.yaml
file. The only values that you must modify are to set the controlPlaneVIP:
address and then set the kind:
as MetalLB. See the following code snippet for an example:
# (Required) Load balancer configuration loadBalancer: # (Required) The VIPs to use for load balancing vips: # Used to connect to the Kubernetes API controlPlaneVIP: "10.61.181.230" # # (Optional) Used for admin cluster addons (needed for multi cluster features). Must # # be the same across clusters # addonsVIP: "" # (Required) Which load balancer to use "F5BigIP" "Seesaw" "ManualLB" or "MetalLB". # Uncomment the corresponding field below to provide the detailed spec kind: MetalLB
When enabling the MetalLB load balancer for Anthos user clusters, there are two areas in each user-cluster.yaml
file that you must update. First, in a manner similar to the admin-cluster.yaml
file, you must modify the controlPlaneVIP:
, ingressVIP:
, and kind:
values in the loadBalancer:
section. See the following code snippet for an example:
loadBalancer: # (Required) The VIPs to use for load balancing vips: # Used to connect to the Kubernetes API controlPlaneVIP: "10.61.181.240" # Shared by all services for ingress traffic ingressVIP: "10.61.181.244" # (Required) Which load balancer to use "F5BigIP" "Seesaw" "ManualLB" or "MetalLB". # Uncomment the corresponding field below to provide the detailed spec kind: MetalLB
The ingressVIP IP address must exist within the pool of IP addresses assigned to the MetalLB load balancer later in the configuration. |
You then need to navigate to the metalLB:
subsection and modify the addressPools:
section by naming the pool in the - name:
variable. You must also create a pool of ip-addresses that MetalLB can assign to services of type LoadBalancer by providing a range to the addresses:
variable.
# # (Required when using "MetalLB" kind in user clusters) Specify the MetalLB config metalLB: # # (Required) A list of non-overlapping IP pools used by load balancer typed services. # # Must include ingressVIP of the cluster. addressPools: # # (Required) Name of the address pool - name: "default" # # (Required) The addresses that are part of this pool. Each address must be either # # in the CIDR form (1.2.3.0/24) or range form (1.2.3.1-1.2.3.5). addresses: - "10.61.181.244-10.61.181.249"
The address pool can be provided as a range like in the example, limiting it to a number of addresses in a particular subnet, or it can be provided as a CIDR notation if the entire subnet is made available. |
-
When Kubernetes services of type LoadBalancer are created, MetalLB automatically assigns an externalIP to the services and advertises the IP address by responding to ARP requests.