Updated on 2024-07-23 GMT+08:00

MetalLB for Load Balancing at Layer 4

Kubernetes does not offer an implementation of network load balancers (Services of type LoadBalancer) for bare-metal clusters. Bare-metal cluster operators are left with two types of Services, NodePort and externalIPs, to bring user traffic into their clusters. MetalLB aims to redress this imbalance by offering a network load balancer implementation, so that external services on bare-metal clusters can work better. For details about MetalLB, see the official projects of the community and the MetalLB official website.

This section describes how to create and use MetalLB in on-premises clusters.

Constraints

Currently, MetalLB can be installed only in on-premises clusters.

Prerequisites

You have enabled BGP for your on-premises cluster and configured LOAD_BALANCER_CIDR to broadcast the load balancer CIDR block to the underlying network.

Installing MetalLB

  1. Log in to the UCS console.
  2. In the navigation pane on the left, choose Operator Service Center.
  3. Search for MetalLB in the service center and click the name of MetalLB to access its details page.

    Figure 1 Searching for MetalLB

  4. Subscribe to MetalLB, click Create Instance, and select the target cluster. Complete the installation as prompted.

Function Verification

  1. Access the cluster details page.

    • If the cluster is not added to any fleet, click the cluster name.
    • If the cluster has been added to a fleet, click the fleet name. In the navigation pane, choose Clusters > Container Clusters.

  2. In the navigation pane on the left, choose Workloads. On the displayed page, click Create from Image.
  3. Select an available image to create a workload and add a LoadBalancer Service. For details, see Workload Service Configuration.
  4. Click the service name, copy the IP address of the load balancer for access from a node outside the cluster to verify that the access is successful.

    Figure 2 Load balancer IP address