Skip to content
lorebow

Where MetalLB runs

Which network plugins, Kubernetes distributions and clouds MetalLB works with, why most public clouds don't, and how to run it beside Calico's BGP.

KFounder and editor Written for MetalLB v0.16.2 843 words 4 min read Find it on the map

MetalLB needs two things from its surroundings: nothing else in the cluster handing out LoadBalancer addresses, and a network that behaves like a real one, where ARPAddress Resolution Protocol: how an IPv4 machine asks who has an address and learns which network card to send to. reaches the nodes or routers accept BGPBorder Gateway Protocol: how routers tell each other which addresses they can reach, and through whom. from them. Most bare-metal and virtual-machine setups give it both. Most public clouds give it neither.

#Network plugins

MetalLB doesn't care much which network plugin (CNIContainer Network Interface: the plugin that gives pods their addresses and connects them, such as Calico, Cilium or Flannel.) you run, as long as it behaves the way Kubernetes expects. These are the ones the project has tested:

PluginWorksNotes
AntreaYesTested on 1.4 and 1.5
CalicoMostlyFine in layer 2; BGP mode clashes with Calico's own BGP (below)
CanalYes
CiliumYes
FlannelYes
Kube-OVNYes
kube-routerMostlyCan't use MetalLB's BGP mode if kube-router peers with your routers itself

Plugins that aren't listed probably work; nobody has reported on them.

#MetalLB beside Calico

Calico usually runs its own BGP daemon on every node, peered with the rack router to share pod routes. BGP allows only one session between two machines, so MetalLB's speaker on the same node can't open a second one.

Each tab in the figure is one scenario:

TabWhat it shows
The conflictCalico already has a BGP session from node-1 to the rack router, so the router refuses MetalLB’s second one.
Calico announcesMetalLB only hands out addresses, and Calico’s existing session advertises them.
Peer with the spineMetalLB peers with the spine router instead, where there’s no session yet, at the cost of one spine session per node.

There are three ways round it:

Let Calico announce

From Calico 3.18, list your pools in Calico's serviceLoadBalancerIPs. MetalLB only hands out addresses (no BGPAdvertisement), and Calico advertises them, as whole CIDRsClassless Inter-Domain Routing notation: an address, a slash and how many leading bits are fixed. 192.168.10.0/24 is the 256 addresses 192.168.10.0 to 192.168.10.255..

Peer with the spine

Point MetalLB's BGPPeers at the spine routers instead of the rack routers. It costs one spine session per node, so limit speakers to a few racks in big clusters.

Split the router

On routers with VRFsVirtual Routing and Forwarding: several separate routing tables inside one router., peer Calico and MetalLB with different halves and leak routes between them. Possible in theory; metallb.io knows of no working example.

Layer 2 mode avoids the problem entirely, because it doesn't use BGP.

#Kubernetes distributions

Some distributions ship their own small load balancer. Two controllers handing out addresses for the same Services will fight, so turn the built-in one off first.

k3s turns on its own load balancer, ServiceLB (formerly Klipper), by default. Start every server with it disabled:

/etc/rancher/k3s/config.yamlyaml
disable:
  - servicelb

The same as the --disable=servicelb flag. With it on, you'll see svclb-… pods in kube-system for each LoadBalancer Service.

#Clouds

Cloud networks are virtual, and they don't behave like Ethernet:

  • ARP is answered by the cloud, from its list of addresses it gave to VMsVirtual machine: a computer emulated in software, the kind clouds rent out.. A request for a Service address never reaches your node, so layer 2 mode can't work.
  • BGP is rare, and where it exists it's usually for bringing routes in from your own data centre, not for VMs to announce addresses.
  • Public "floating" IP addresses move through the provider's API, which MetalLB doesn't call.
PlatformWorks with MetalLB
AWSAmazon Web Services, Amazon’s cloud., Azure, Google Cloud, DigitalOceanNo: use each cloud’s own Kubernetes (Amazon EKS, Azure AKS, Google GKE, DigitalOcean Kubernetes) and its load balancer
Hetzner, VultrYes
OVHcloudYes, with a vRack, OVHcloud’s private network between servers
Proxmox, VMwareYes
OpenStackYes, with ARP spoofing protection turned off
OpenShiftYes, with the changes below
OpenStack: turn off ARP spoofing protection

In layer 2 mode a node answers ARP for addresses OpenStack never gave it, which OpenStack's port security treats as an attack and drops. Turn the protection off on every VM that runs Kubernetes. There's no way to tell OpenStack about MetalLB's addresses instead.

OpenShift: UIDs and privileges

OpenShift assigns pod UIDsUser ID: the numeric user a container’s processes run as. itself, so remove spec.template.spec.securityContext.runAsUser and fsGroup from the controller DeploymentA Kubernetes workload that keeps a set number of identical pods running. and the speaker DaemonSetA Kubernetes workload that runs one copy of a pod on every node, or on every selected node.. Then let the speaker do raw networking:

bash
oc adm policy add-scc-to-user privileged -n metallb-system -z speaker

With the HelmA package manager for Kubernetes: a chart bundles all of an app’s objects, installed with one command and settings from a values file. chart the service account is metallb-speaker.

If MetalLB can't run where you are, the fallback metallb.io suggests is keepalived-vip: Keepalived with a script that calls your cloud's APIApplication Programming Interface: the requests one program accepts from others, like the Kubernetes API or a cloud provider’s API. on failover. It doesn't make LoadBalancer Services work, and mostly makes sense in front of an ingress controllerAn HTTP proxy inside the cluster (an Ingress controller or a Gateway API implementation) that routes requests to Services by host name and path..

#Watch it happen

Before installing, check what's already there:

bash
kubectl get pods -n kube-system -o wide | grep -E 'svclb|calico|cilium|flannel|kube-router'
kubectl -n kube-system get configmap kube-proxy -o yaml | grep -E 'mode:|strictARP'
kubectl get services -A | grep LoadBalancer

svclb- pods mean k3s's ServiceLB is on. mode: ipvs with strictARP: false needs changing before layer 2 mode will work. LoadBalancer Services that already have an EXTERNAL-IP have one from some other controller.

#In the source

These pages of metallb.io live in the MetalLB repository, at website/content/: