MetalLB: Load Balancers Without Cloud Providers
Running Kubernetes on bare metal? No AWS ELB, no GCP Load Balancer. Your LoadBalancer services stay in "Pending" forever. MetalLB fixes this by providing network load balancers for bare metal clusters.
How MetalLB Works
MetalLB operates in two modes:
- Layer 2 (ARP/NDP) — simple, works everywhere, single-node bottleneck
- BGP — production-grade, true load balancing across nodes
The Free API (CRDs)
MetalLB is configured entirely through Kubernetes CRDs:
apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
name: production-pool
namespace: metallb-system
spec:
addresses:
- 192.168.1.240-192.168.1.250
---
apiVersion: metallb.io/v1beta1
kind: L2Advertisement
metadata:
name: l2-advert
namespace: metallb-system
spec:
ipAddressPools:
- production-pool
# Check allocated IPs
kubectl get ipaddresspools -n metallb-system
# See which services got IPs
kubectl get svc -A | grep LoadBalancer
# BGP session status
kubectl get bgppeers -n metallb-system
Real-World Use Case
A fintech company running on-prem Kubernetes for compliance reasons couldn't use cloud load balancers. MetalLB with BGP mode gave them production-grade load balancing with failover — no cloud dependency, full data sovereignty.
Quick Start
kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.14.5/config/manifests/metallb-native.yaml
# Wait for pods
kubectl wait --namespace metallb-system --for=condition=ready pod --selector=app=metallb -l 120s
Layer 2 vs BGP
| Feature | Layer 2 | BGP |
|---|---|---|
| Setup | Simple | Requires router config |
| Failover | ~10s | Sub-second |
| Load distribution | Single node | All nodes |
| Best for | Dev/small clusters | Production |
Key Features
- No cloud vendor lock-in — works on any bare metal or VM cluster
- Dual-stack — IPv4 and IPv6 support
- Multiple pools — different IP ranges for different namespaces
- FRR mode — modern BGP implementation with advanced features
Resources
Need automated data collection for your infrastructure? Check out my web scraping tools on Apify or email spinov001@gmail.com for custom solutions.
Top comments (0)