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.
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:
| Tab | What it shows |
|---|---|
| FRR-K8s | The 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 own | Your own FRRConfiguration is merged into the same session. A configuration that conflicts is refused, and FRR keeps its last good one. |
| Native | No 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 default | Native | FRR deprecated | |
|---|---|---|---|
| Who speaks BGP | FRR, 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 Go | FRR, in containers inside each speaker pod |
| BFD, IPv6 routes, VRFs | Yes | No | Yes |
| Share sessions with other tools | Yes, through FRRConfiguration | No | No |
| BGP metrics prefix | frrk8s_ | metallb_ | metallb_ |
| New features | All new BGP features land here | Kept, no new features | Will 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:
- The speaker writes an
FRRConfigurationfor its node, namedmetallb-<node>, with the peers and routes MetalLB wants. - frr-k8s on that node merges every
FRRConfigurationthat 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:
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/0This 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
# FRR-K8s (the default): nothing to set.
# Native:
speaker:
frr:
enabled: false
frrk8s:
enabled: false
# FRR mode (deprecated):
# speaker:
# frr:
# enabled: true
# frrk8s:
# enabled: falseThe 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
BGPPeeron a node must use the samemyASNand the samerouterID. - 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
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 yamlWith 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
speaker/main.go: readsMETALLB_BGP_TYPEand starts the matching backend.internal/bgp/frrk8s/frrk8s.go: builds themetallb-<node>FRRConfiguration.internal/bgp/native/: the native BGP speaker.internal/config/validation.go:DiscardFRROnlylists everything the native backend refuses.- metallb/frr-k8s at v0.0.27: the FRR-K8s daemon, with the merge rules in its README.