Bare-metal k8s: a stable Cilium L2 LoadBalancer during node maintenance

Published: 2026-07-13

On bare-metal Kubernetes, the first production problem is not scheduling pods. It is keeping the external IP reachable when the node behind it changes: after a reboot, a drain or a service move. In this post I show how to make Cilium L2 LoadBalancer IPs stable, which node network settings matter, and how to do upgrades and reboots without losing access to services.


The problem

In the cloud, a LoadBalancer service gets an external address automatically. On bare metal there is no cloud controller to do this. Kubernetes can assign an EXTERNAL-IP, but nothing announces that IP on the physical network.

As a result, the service looks healthy inside the cluster, but it does not answer from outside. No node answers ARP/NDP requests for this address, so the rest of the network does not know where to send packets.

It gets worse when you reboot or drain nodes. The service may move, but clients still use old ARP/NDP entries and send traffic to the old MAC. On a physical LAN, one wrong announcement or a missing rp_filter setting is enough to make the load balancer address disappear.

bash$ kubectl get svc apisix -n ingress-apisix
NAME    TYPE           CLUSTER-IP    EXTERNAL-IP      PORT(S)
apisix  LoadBalancer   10.96.45.23   172.16.57.193    80:32000/TCP

The IP is there, but until some node owns it on the network, nobody can reach it.

How it works

Cilium L2 announcements give the service IP an owner on the network, at the ARP/NDP level.

  • CiliumLoadBalancerIPPool defines the pool of addresses that Cilium gives to LoadBalancer services.
  • CiliumL2AnnouncementPolicy controls which nodes announce these IPs and on which interfaces.
  • When you create a service, Cilium takes an IP from the pool and starts answering ARP/NDP for it on the chosen interface.
  • If the service moves to another node, Cilium removes the old announcement, and the new node takes over the same IP.

The key point: Kubernetes only knows the service IP. Whether the IP is reachable depends on Cilium managing ARP/NDP on the physical interface.

Why host network settings matter

On bare metal, the usual problems are packet forwarding and reverse path filtering in the Linux kernel:

  • net.ipv4.ip_forward=1 is required so the node can forward traffic between interfaces.
  • net.ipv4.conf.all.rp_filter=0 and net.ipv4.conf.default.rp_filter=0 are required when the node receives traffic for a service IP and forwards it to a pod through Cilium.
  • net.ipv4.conf.<iface>.rp_filter=0 helps when the IP is announced on one interface, but the main route goes through another.

If rp_filter is 1, the kernel may drop valid replies because the return path does not match the incoming interface.

When you need a fixed IP

In production, set a specific loadBalancerIP. Then DNS, firewall rules, NAT and port-based access control always work with a known address.

yamlapiVersion: v1
kind: Service
metadata:
  name: apisix
  namespace: ingress-apisix
spec:
  type: LoadBalancer
  loadBalancerIP: 172.16.57.193
  ports:
    - port: 80
      targetPort: 80
  selector:
    app: apisix

Cilium will take exactly this IP from the pool, or return an error if the address is already in use.

Setup

Step 1: define the pool

Choose a block inside your LAN that DHCP does not use and that does not overlap with other services. A /28 gives you 14 usable IPs.

yamlapiVersion: cilium.io/v2alpha1
kind: CiliumLoadBalancerIPPool
metadata:
  name: baremetal-lb-pool
spec:
  blocks:
    - cidr: 172.16.57.192/28   # 14 usable IPs

Apply it with kubectl apply -f cilium-lb-pool.yaml.

Step 2: limit announcements to the right nodes and interface

Pick the physical interface that connects to the upstream router or switch, the one that client traffic actually reaches. If your node uses bonded interfaces, use the bond name.

yamlapiVersion: cilium.io/v2alpha1
kind: CiliumL2AnnouncementPolicy
metadata:
  name: baremetal-l2-policy
spec:
  serviceSelector:
    matchLabels:
      app.kubernetes.io/managed-by: Flux
  nodeSelector:
    matchLabels:
      kubernetes.io/os: linux
      node-role.kubernetes.io/worker: ""
  interfaces:
    - eth0
  externalIPs: true
  loadBalancerIPs: true

The interfaces field is the most important guard. If Cilium announces on the wrong NIC, or on a bridge that is not connected to the LAN, the address will never reach clients.

Step 3: tune node networking

Set these sysctls on every bare-metal node:

bashcat <<'EOF' | sudo tee /etc/sysctl.d/99-cilium-l2.conf
net.ipv4.ip_forward=1
net.ipv4.conf.all.rp_filter=0
net.ipv4.conf.default.rp_filter=0
net.ipv4.conf.eth0.rp_filter=0
EOF
sudo sysctl --system

If your nodes have several physical NICs or VLANs, add net.ipv4.conf.<iface>.rp_filter=0 for the interface you chose.

Step 4: check that Cilium sees the pool and the policy

bashkubectl get ciliumloadbalancerippool -A
kubectl get ciliuml2announcementpolicy -A
kubectl describe ciliuml2announcementpolicy baremetal-l2-policy

The pool should be in the Active state, and the policy should apply to worker nodes.

Step 5: create a LoadBalancer service

Apply a service with loadBalancerIP, then check that the external IP appears:

bashkubectl apply -f apisix-service.yaml
kubectl get svc apisix -n ingress-apisix -o wide

Then test access from outside the cluster:

bashcurl -I http://172.16.57.193

If there is no answer, check ARP on the upstream router or on a client:

baship neigh show 172.16.57.193

A good result looks like this:

text172.16.57.193 dev eth0 lladdr 52:54:00:12:34:56 REACHABLE

Step 6: make maintenance safe

For maintenance, use the usual drain and reboot steps, as for any Kubernetes node. Just remember that the service can lose its IP while the node reboots.

bashkubectl drain node-01 --ignore-daemonsets --delete-emptydir-data
sudo reboot

During a reboot, Cilium stops announcing the address. The service is unreachable until another node takes the address over.

To make failover predictable:

  • use one pool for the whole cluster
  • set a fixed loadBalancerIP for production services
  • let only worker nodes announce IPs
  • keep ARP cache timeouts short on upstream devices, if you manage them

When the node comes back to the cluster, Cilium should restore the announcement automatically.

What can go wrong

The IP stays pending. Usually the service does not match the policy, or the pool has no free addresses.

bashkubectl get svc apisix -n ingress-apisix -o jsonpath='{.status.loadBalancer.ingress}'
  • Check that CiliumLoadBalancerIPPool has free blocks.
  • Check the CiliumL2AnnouncementPolicy selectors and the interfaces field.
  • Check that the service labels match the policy selector.

Clients see the wrong MAC. If two nodes announce the same IP, upstream ARP caches can switch between two MACs.

  • Run ip neigh show <ip> on a client.
  • Run sudo tcpdump -nei eth0 arp or icmp on the nodes that could be announcing.
  • Check that policies don't overlap and the IP pool is not used anywhere else.

After a reboot, the service is still unreachable. The cluster may be fine already, but the router or client still has an old ARP entry.

  • Clear the ARP entry on the router or client, if you can.
  • Reduce the ARP cache timeout on your switch or router, or use a shorter ip neigh entry lifetime on Linux clients.
  • Check Cilium on the Kubernetes node: kubectl get pods -n kube-system -l k8s-app=cilium and kubectl logs show whether it restarted cleanly.

The address is announced on the wrong interface. This is the most common bare-metal problem.

bashkubectl describe ciliuml2announcementpolicy baremetal-l2-policy
  • Check that interfaces: points to the LAN-facing interface.
  • Check that the firmware or cloud-init did not rename the interface.
  • Check that ip route and ip addr show the chosen interface as the one used for external traffic.

Summary

  • On bare-metal Kubernetes, LoadBalancer IPs need an owner on the network. Cilium L2 announcements do this job through ARP/NDP.
  • Define a pool, limit announcements to the LAN-facing interface and set fixed IPs for production services.
  • Set ip_forward and rp_filter on bare-metal nodes, or the kernel may drop reply packets.
  • During a drain or reboot, the external IP can disappear until another node takes it over.
  • Most failures come down to one of these: policy mismatch, wrong interface, overlapping IP ranges or an old ARP entry on the upstream network.