From point A to point B
Point A: your LoadBalancer services get an external IP from LB IPAM, but nobody on the network knows how to reach it. Point B: by the end of this chapter you'll be able to announce those IPs on the local network with ARP or to your routers with BGP, and choose the method that fits your environment.
The NodePort problem
A NodePort service opens the same port on every node. It's simple, but it forces the client to decide twice:
- Which node to connect to. The client picks it, and if that node goes down, nobody redirects it: the client has to notice and try another IP.
- Which pod it reaches. This one the cluster does solve, as you saw in chapter 6.
The first decision is fragile. Cilium solves it with two mechanisms that make a service IP truly reachable: layer 2 announcements and BGP.
One node answers ARP, or all of them announce routes. Diagram: The House of Routing.
Layer 2 announcements
With layer 2 announcements (also called L2 Aware LB), Cilium answers ARP requests for your service IPs. Those IPs are virtual: they don't belong to any interface. For each one, the nodes elect a leader through a Kubernetes lease, and that node replies with its MAC address. Since Cilium 1.19 it also works with IPv6, using Neighbor Discovery instead of ARP. The feature is still in beta.
It requires kube-proxy replacement. Use the kind-no-kube-proxy.yaml from chapter 6:
# values-l2.yaml
kubeProxyReplacement: true
k8sServiceHost: kind-control-plane
k8sServicePort: 6443
l2announcements:
enabled: true
k8sClientRateLimit: # leader election makes more calls to the API server
qps: 20
burst: 40
The service IP has to be on the same network as the client. In kind, the Docker network is usually 172.18.0.0/16; check it with docker network inspect kind. Create a pool, an application and a service labeled to be announced:
# l2-lab.yaml
apiVersion: cilium.io/v2
kind: CiliumLoadBalancerIPPool
metadata:
name: lab-pool
spec:
blocks:
- start: 172.18.255.200
stop: 172.18.255.210
---
apiVersion: v1
kind: Service
metadata:
name: whoami
labels:
announce: l2
spec:
type: LoadBalancer
selector:
app: whoami
ports:
- port: 80
kubectl create deployment whoami --image=traefik/whoami --replicas=2
kubectl apply -f l2-lab.yaml
kubectl get svc whoami # EXTERNAL-IP: 172.18.255.200
The service already has an IP, but nobody answers for it yet. You're missing the policy that says which services get announced, from which nodes and on which interfaces:
# l2-policy.yaml
apiVersion: cilium.io/v2alpha1
kind: CiliumL2AnnouncementPolicy
metadata:
name: lab-l2
spec:
serviceSelector:
matchLabels:
announce: l2
nodeSelector: # workers only: the control plane carries no traffic
matchExpressions:
- key: node-role.kubernetes.io/control-plane
operator: DoesNotExist
interfaces:
- ^eth0 # regular expression; without it, every interface
loadBalancerIPs: true
kubectl apply -f l2-policy.yaml
# Which node won the lease for this IP
kubectl -n kube-system get lease | grep l2announce
# A client on the kind network: first ARP, then HTTP
docker run -d --rm --network kind --name lan-client nicolaka/netshoot sleep infinity
docker exec lan-client curl -s http://172.18.255.200 | grep Hostname
docker exec lan-client ip neigh | grep 172.18.255.200
# 172.18.255.200 dev eth0 lladdr … REACHABLE ← the leader node's MAC
If you want to watch the exchange, run docker exec lan-client tcpdump -ni eth0 arp or port 80 in another terminal. You'll see the client's who-has, the leader node's is-at reply and then the TCP connection.
interfaces filter isn't a security measure: the service can still be reachable through other interfaces if someone configures ARP by hand.What happens when a node goes down
LEADER=$(kubectl -n kube-system get lease cilium-l2announce-default-whoami -o jsonpath='{.spec.holderIdentity}')
docker stop $LEADER
docker exec lan-client curl -s -m 5 http://172.18.255.200
# timeout: the client's ARP cache still points to the downed node's MAC
When the lease expires, another node takes it and sends a gratuitous ARP to announce the new MAC. If the client accepts it, the switch is almost immediate. Many devices ignore it for security reasons (gratuitous ARP is used in spoofing attacks), and then you have to wait for their ARP cache to expire.
kubectl -n kube-system get lease | grep l2announce # new leader
docker exec lan-client curl -s -m 5 http://172.18.255.200 | grep Hostname
docker start $LEADER
Limitations of layer 2 announcements:
- A single node serves each IP: there's no load balancing across nodes.
- Failover depends on ARP caches and can be slow.
- The client has to be on the same layer 2 network.
It's a good option for labs, small offices or environments without BGP routers. Cilium can also announce pod IPs (l2podAnnouncements), but it isn't recommended: announce services, not pods.
BGP: the production approach
With BGP, each selected node announces the service IPs to your routers as layer 3 routes. If several nodes announce the same IP, the router spreads traffic across them with ECMP (Equal-Cost Multi-Path). If a node goes down, its route disappears and traffic keeps flowing through the rest.
Cilium's BGP control plane is configured with three resources that link to each other:
Nodes and neighbors, how to talk to them and what to announce. Diagram: The House of Routing.
| Resource | What it defines |
|---|---|
CiliumBGPClusterConfig | Which nodes speak BGP, their local ASN and the list of neighbors |
CiliumBGPPeerConfig | Reusable per-neighbor settings: timers, address families, graceful restart, MD5 password |
CiliumBGPAdvertisement | What gets announced: service IPs, PodCIDR, Multi-Pool pools or interface addresses |
CiliumBGPPeeringPolicy resource belongs to the first version of the control plane. The examples in this chapter use the current resources, introduced in Cilium 1.16.Build the BGP lab
You'll simulate a router with FRR (Free Range Routing) in a container on the kind network. We'll use eBGP: the cluster in ASN 65000 and the router in 65100. Install Cilium with BGP enabled:
helm upgrade cilium cilium/cilium --version 1.20.3 -n kube-system \
--reuse-values --set bgpControlPlane.enabled=true --set l2announcements.enabled=false
kubectl -n kube-system rollout restart deployment/cilium-operator daemonset/cilium
kubectl get nodes -o wide # note the workers' INTERNAL-IP
The router configuration. Replace the neighbor IPs with your workers' IPs:
mkdir frr && cd frr
printf 'bgpd=yes\nzebra=yes\n' > daemons
touch vtysh.conf
cat > frr.conf <<'EOF'
frr defaults traditional
hostname thor-router
router bgp 65100
bgp router-id 172.18.0.250
no bgp ebgp-requires-policy
neighbor CILIUM peer-group
neighbor CILIUM remote-as 65000
neighbor 172.18.0.2 peer-group CILIUM
neighbor 172.18.0.3 peer-group CILIUM
address-family ipv4 unicast
maximum-paths 8
exit-address-family
EOF
docker run -d --rm --privileged --network kind --ip 172.18.0.250 --name thor-router \
-v "$PWD:/etc/frr" quay.io/frrouting/frr:10.3.1
docker exec thor-router vtysh -c "show bgp summary" # neighbors in Active state
Active means the router is trying to connect, but nobody is answering yet. Now the Cilium side:
# cilium-bgp.yaml
apiVersion: cilium.io/v2
kind: CiliumBGPClusterConfig
metadata:
name: thor-bgp
spec:
nodeSelector:
matchExpressions:
- key: node-role.kubernetes.io/control-plane
operator: DoesNotExist
bgpInstances:
- name: as65000
localASN: 65000
peers:
- name: thor-router
peerASN: 65100
peerAddress: 172.18.0.250
peerConfigRef:
name: thor-peer
---
apiVersion: cilium.io/v2
kind: CiliumBGPPeerConfig
metadata:
name: thor-peer
spec:
timers:
keepAliveTimeSeconds: 10
holdTimeSeconds: 30 # usually 3 times the keepalive
gracefulRestart:
enabled: true
restartTimeSeconds: 15
families:
- afi: ipv4
safi: unicast
advertisements:
matchLabels:
advertise: bgp # links to the advertisement below
---
apiVersion: cilium.io/v2
kind: CiliumBGPAdvertisement
metadata:
name: lb-services
labels:
advertise: bgp
spec:
advertisements:
- advertisementType: Service
service:
addresses:
- LoadBalancerIP
selector:
matchLabels:
announce: bgp
kubectl apply -f cilium-bgp.yaml
kubectl label service whoami announce=bgp --overwrite
cilium bgp peers # established on each worker
cilium bgp routes advertised ipv4 unicast # 172.18.255.200/32 from each node
docker exec thor-router vtysh -c "show ip route bgp"
# B>* 172.18.255.200/32 via 172.18.0.2 … via 172.18.0.3 ← two paths, ECMP
docker exec thor-router wget -qO- http://172.18.255.200 | grep Hostname
A few details that matter in production:
- Graceful restart: when the agent restarts, the router keeps the routes for
restartTimeSecondsinstead of withdrawing them all at once. That way a Cilium upgrade doesn't cut traffic. - Authentication: by default BGP doesn't authenticate. Turn on MD5 with
authSecretRefin the CiliumBGPPeerConfig. - Attributes: you can add communities or
localPreferenceto each advertisement so your network treats those routes differently. - externalTrafficPolicy: with
Cluster, every selected node announces the IP; withLocal, only the ones that have a backend.
How to choose
| Layer 2 announcements | BGP | |
|---|---|---|
| Requirements | None: clients on the same network | BGP-capable routers and routing know-how |
| Load balancing | No: one node per IP | Yes, with ECMP |
| Failover | Slow: depends on ARP | Fast: the route is withdrawn |
| Reach | Same layer 2 network | Any routed network |
| Best for | Labs and small environments | Production |
In both cases, announce services, not pods: the service already handles lifecycle, failover and load balancing.
# Cleanup
docker rm -f lan-client thor-router
Challenge
Answer before you open the solution.
1. With layer 2 announcements, how many nodes receive the traffic for a service IP?
One: the one holding the lease for that IP. It then spreads the traffic across the pods.
2. The leader node goes down and the client still can't connect for a while. Why?
Its ARP cache still points to the downed node's MAC and it probably ignores the new leader's gratuitous ARP.
3. Which resource decides which prefixes are announced over BGP?
CiliumBGPAdvertisement, linked by label from the CiliumBGPPeerConfig.
4. What lets the router spread traffic across several nodes?
ECMP: several nodes announce the same IP and the router installs a route with multiple next hops.
What you take away
- NodePort leaves node selection and failover to the client.
- Layer 2 announcements answer ARP for the service IP from a leader node.
- BGP announces the IP from several nodes; the router balances with ECMP and fails over fast.
- Three resources: ClusterConfig (who and with whom), PeerConfig (how) and Advertisement (what).
- Announce services, not pods.
In the next chapter, the opposite direction: traffic leaving the cluster, with masquerading, Egress Gateway and Bandwidth Manager.
Official resources
- L2 Announcementsdocs.cilium.io
- BGP Control Plane Resourcesdocs.cilium.io
- BGP Control Plane Operation Guidedocs.cilium.io
- FRRouting: BGPfrrouting.org
- RFC 4271 · BGP-4ietf.org
- Cilium: Up and Running (book)isovalent.com
Source and credits. This chapter summarizes and paraphrases the official book Cilium: Up and Running by Nico Vibert, Filip Nikolic and James Laverack (O'Reilly Media, 2026). The summary was produced with AI and reviewed, verified and approved by Jesús Espinoza. The diagrams and code examples are original work by The House of Routing and were checked against the official Cilium documentation. Cilium: Up and Running, the cover image, and related trade dress are trademarks of O'Reilly Media, Inc. This content is not affiliated with or endorsed by O'Reilly Media or Isovalent.