Skip to content
lorebow

BGP backends

The three programs MetalLB can use to speak BGP, FRR-K8s, native and FRR, what each can and can't do, and how FRR-K8s lets other tools share the same sessions.

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

The speaker decides what to advertise. Something still has to hold the BGPBorder Gateway Protocol: how routers tell each other which addresses they can reach, and through whom. sessions and send the routes, and MetalLB has three options for that, picked when you install it. Layer 2 mode doesn't use any of them, so if you only use layer 2 you can skip this page.

Each tab in the figure is one scenario:

TabWhat it shows
FRR-K8sThe default. The speaker writes what it wants as an FRRConfiguration, frr-k8s turns that into FRR’s configuration, and FRR talks to the router.
Merge your ownYour own FRRConfiguration is merged into the same session. A configuration that conflicts is refused, and FRR keeps its last good one.
NativeNo FRR at all: the speaker talks BGP itself, and refuses options it can’t do, such as BFDBidirectional Forwarding Detection: two machines send each other tiny hello packets every few hundred milliseconds, so a dead link or node is noticed in under a second..
FRR (deprecated)The old way: FRR runs inside each speaker pod and the speaker writes its configuration file directly.
FRR-K8s defaultNativeFRR deprecated
Who speaks BGPFRR, in a separate frr-k8s-daemon DaemonSetA Kubernetes workload that runs one copy of a pod on every node, or on every selected node.The speaker itself, in GoFRR, in containers inside each speaker pod
BFD, IPv6 routes, VRFsYesNoYes
Share sessions with other toolsYes, through FRRConfigurationNoNo
BGP metrics prefixfrrk8s_metallb_metallb_
New featuresAll new BGP features land hereKept, no new featuresWill be removed

FRRFRRouting: open-source routing software (BGP, BFD, OSPF and more) used in many routers and Linux networks. is a full routing suite, the same software many routers run. Using it gives MetalLB everything FRR can do, and the FRR-K8s layer adds a Kubernetes APIApplication Programming Interface: the requests one program accepts from others, like the Kubernetes API or a cloud provider’s API. on top of it. In the table, BFD detects a dead neighbour in under a second, and a VRFVirtual Routing and Forwarding: a separate routing table inside one machine or router, so two networks can be kept apart. is a separate routing table.

#FRR-K8s, the default

Since v0.16.0 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 and the main manifest install FRR-K8s. It works in two steps, as the first scenario shows:

  1. The speaker writes an FRRConfiguration for its node, named metallb-<node>, with the peers and routes MetalLB wants.
  2. frr-k8s on that node merges every FRRConfiguration that selects the node, renders one FRR configuration, and reloads FRR. FRR holds the sessions.

frr-k8s reports what it did in two more resources: FRRNodeState (the running config and whether the last reload worked) and BGPSessionState (one per session, with its BGP and BFD state).

#Sharing the session with your own config

This is the reason FRR-K8s exists. BGP allows one session between two machines, so before FRR-K8s, MetalLB and any other tool that wanted to talk BGP from the node had to fight over it. Now any tool, or you, can add an FRRConfiguration for the same node, and frr-k8s merges it into the same session:

receive-default.yamlyaml
apiVersion: frrk8s.metallb.io/v1beta1
kind: FRRConfiguration
metadata:
  name: receive-default
  namespace: metallb-system
spec:
  bgp:
    routers:
      - asn: 64500
        neighbors:
          - address: 10.0.0.1
            asn: 64501
            toReceive:
              allowed:
                prefixes:
                  - prefix: 0.0.0.0/0

This one accepts a default route from the same router MetalLB advertises to. Leaving out nodeSelector applies it to every node.

The FRRConfiguration must live in the namespace frr-k8s runs in: metallb-system when it comes with MetalLB. If you already run FRR-K8s separately, the Helm chart can use it instead of its own copy (frrk8s.external: true and frrk8s.namespace).

#Native

MetalLB's own BGP code, inside the speaker. There is no FRR and no extra DaemonSet, which makes it the lightest option for layer 2 clusters or a simple IPv4 BGP setup. It refuses configuration it can't honour, with an error such as peer 10.0.0.1 has bfd-profile set on native bgp mode.

Native is enough when

  • You only use layer 2 mode
  • You advertise IPv4 routes to plain BGP peers
  • You want the fewest pods per node

Native refuses

  • BFD profiles, keepalive and connect times
  • VRFs, interface peering, dynamic and local ASN
  • IPv6 advertisements and large communities
  • Graceful restart and dual-stack sessions

Its default hold time is 90 seconds, so a dead node's route can stay on the router for up to a minute and a half.

#FRR, deprecated

Before v0.16.0 this was the Helm chart's default: FRR runs as containers inside every speaker pod, and the speaker writes FRR's configuration file directly. It has FRR-K8s's features except sharing, and it's being removed.

#Choosing the backend

values.yamlyaml
# FRR-K8s (the default): nothing to set.
 
# Native:
speaker:
  frr:
    enabled: false
frrk8s:
  enabled: false
 
# FRR mode (deprecated):
# speaker:
#   frr:
#     enabled: true
# frrk8s:
#   enabled: false

The speaker learns which one it's using from its METALLB_BGP_TYPE environment variable: frr-k8s, native or frr.

#Limits of the FRR-based backends

FRR runs one BGP router per node, so a few things that the native backend allows don't fit it:

  • Every BGPPeer on a node must use the same myASN and the same routerID.
  • An eBGPExternal BGP: a session between two different AS numbers. Internal BGP (iBGP) is between routers of the same AS. peer more than one hop away needs ebgpMultiHop: true.
  • A node can't peer with itself.

#Watch it happen

bash
kubectl -n metallb-system get pods -o wide
kubectl -n metallb-system get frrconfigurations
kubectl get frrnodestates
kubectl -n metallb-system get bgpsessionstates
kubectl get frrnodestates -o yaml

With FRR-K8s you'll see a frr-k8s-daemon pod beside each speaker (with Helm, metallb-frr-k8s and metallb-speaker), one metallb-<node> FRRConfiguration per node, and, in each node's FRRNodeState (a cluster-wide resource), the FRR configuration that was actually loaded.

#In the source