KubernetesCXII · Load Balancing on Bare MetalLoad balancing on bare metal
BGP peer configuration — IP pools, peers, and communities
What you'll learn
- Configure IPAddressPool, BGPPeer, and BGPAdvertisement
- Apply BGP communities for routing policy
- Use multiple pools and peers for multi-tenant BGP
- Apply the operational discipline of BGP peer configuration
Prerequisites
Verified against Kubernetes 1.34.x · kubeadm 1.34.x · kubectl 1.34.x · etcd 3.6.x · CoreDNS 1.11.x · containerd 1.7.x / 2.x · 2026-08-16
BGP peer configuration is the core of MetalLB’s production setup. This lesson walks the configuration pieces, multi-pool and multi-peer scenarios, BGP communities, and the discipline.
The three configuration pieces
flowchart LR
A[IPAddressPool] -->|range of IPs| C[BGPAdvertisement]
B[BGPPeer] -->|router, ASN| C
C -->|advertises IPs| D[Router]
The three pieces:
- IPAddressPool. The range of IPs that can be assigned to LoadBalancer Services.
- BGPPeer. The router’s connection details (IP, ASN, timers, BFD).
- BGPAdvertisement. Binds pools to peers; declares which communities to attach.
A simple configuration
apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
name: prod-pool
namespace: metallb-system
spec:
addresses:
- 192.168.100.0/24
---
apiVersion: metallb.io/v1beta2
kind: BGPPeer
metadata:
name: prod-router
namespace: metallb-system
spec:
peerAddress: 192.168.1.1
peerASN: 64512
myASN: 64513
---
apiVersion: metallb.io/v1beta1
kind: BGPAdvertisement
metadata:
name: prod-advert
namespace: metallb-system
spec:
ipAddressPools:
- prod-pool
peers:
- prod-router
communities:
- 64513:100
A single pool, single peer, single community.
Multi-pool for multi-environment
apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
name: prod-pool
spec:
addresses:
- 192.168.100.0/24
---
apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
name: dev-pool
spec:
addresses:
- 192.168.200.0/24
---
apiVersion: metallb.io/v1beta1
kind: BGPAdvertisement
metadata:
name: prod-advert
spec:
ipAddressPools:
- prod-pool
peers:
- prod-router
communities:
- 64513:100
---
apiVersion: metallb.io/v1beta1
kind: BGPAdvertisement
metadata:
name: dev-advert
spec:
ipAddressPools:
- dev-pool
peers:
- dev-router
communities:
- 64513:200
Two pools, two peers, two communities. Production and development traffic are advertised to different routers with different communities.
Multi-peer for redundancy
apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
name: prod-pool
spec:
addresses:
- 192.168.100.0/24
---
apiVersion: metallb.io/v1beta2
kind: BGPPeer
metadata:
name: router-1
spec:
peerAddress: 192.168.1.1
peerASN: 64512
myASN: 64513
---
apiVersion: metallb.io/v1beta2
kind: BGPPeer
metadata:
name: router-2
spec:
peerAddress: 192.168.2.1
peerASN: 64514
myASN: 64513
---
apiVersion: metallb.io/v1beta1
kind: BGPAdvertisement
metadata:
name: prod-advert
spec:
ipAddressPools:
- prod-pool
peers:
- router-1
- router-2
A single pool advertised to two routers. Both routers learn the routes; either router can forward traffic. If router-1 fails, router-2 continues.
BGP communities
flowchart LR
A[MetalLB advertises IP] --> B["With community 64513:100"]
B --> C[Router receives]
C --> D{Match community?}
D -->|64513:100| E[Apply policy A]
D -->|64513:200| F[Apply policy B]
D -->|No match| G[Default policy]
BGP communities tag routes for routing policy:
64513:100— production pool.64513:200— development pool.64513:300— backup pool.
The router’s route map matches on community and applies different policies (local-preference, MED, prepending).
The operational trade-offs
flowchart LR
A["Single pool, single peer"] --> B[+ Simple]
A --> C[- Single point of failure]
D["Multi-pool, multi-peer"] --> E["+ HA, multi-env"]
E --> F[- Operational complexity]
The trade-offs:
Single pool, single peer:
- Pros: Simple.
- Cons: Single point of failure.
Multi-pool, multi-peer:
- Pros: HA; multi-environment; multi-tenant.
- Cons: Operational complexity; more configuration to maintain.
Quiz
Knowledge check · 4 questions
Q1. What are BGP communities used for in a MetalLB deployment?
Q2. BGP communities carry no authentication or authorisation properties of their own.
Q3. Stop a development Service from drawing an address out of the production pool and give it its own routing policy.
One IPAddressPool named all-pool covers 192.168.100.0/22 and a single BGPAdvertisement attaches community 64513:100 to everything it advertises. A Service in namespace dev-team receives 192.168.100.7 and is now advertised with the production community, so the router applies local-preference 200 to it and prefers it over a genuinely production route. Both environments share one pool and one advertisement.
Q4. Which MetalLB object binds an IPAddressPool to a BGPPeer, and what is observable if that object is missing?
Passing score: 75%. Answers are checked in this browser.
The operational discipline
BGP peer configuration rests on five non-negotiable elements:
- IP pool boundaries. Document which pool is production, which is development.
- Peer configuration. Document each peer’s IP, ASN, timers, BFD.
- Communities for routing policy. Use communities to tag routes; match on the router side.
- Multi-peer for HA. At least two routers for production.
- Verify BGP sessions. After every change.
BGP peer configuration is production networking. The discipline is to document every piece and verify every change.