MetalLB
Purpose: Load balancer for bare-metal Kubernetes clusters
Version: 0.14.8
Namespace: metallb-system
Description
Provides network load balancing for clusters that don't run on a cloud provider with built-in load balancers. Uses Layer 2 (ARP) mode for IP address announcement.
Installation
Installed via ArgoCD from Helm chart: metallb/metallb
Configuration
Configuration is managed via cluster-configs.yaml template which creates:
IPAddressPool
apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
name: default-pool
namespace: metallb-system
spec:
addresses:
- 10.0.0.210-10.0.0.250
autoAssign: true
Pool Range: 10.0.0.210 - 10.0.0.250 (41 addresses)
L2Advertisement
apiVersion: metallb.io/v1beta1
kind: L2Advertisement
metadata:
name: default
namespace: metallb-system
spec:
ipAddressPools:
- default-pool
Usage
Services of type LoadBalancer automatically get an IP from the pool:
kubectl get svc -n ingress-nginx
# NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S)
# ingress-nginx-controller LoadBalancer 10.96.89.123 10.0.0.211 80:30081/TCP,443:30080/TCP
Example Service
apiVersion: v1
kind: Service
metadata:
name: my-app
namespace: default
spec:
type: LoadBalancer
ports:
- port: 80
targetPort: 8080
selector:
app: my-app
Components
| Component | Purpose |
|---|---|
| metallb-controller | IP address allocation and management |
| metallb-speaker | ARP announcer (runs as DaemonSet) |
How It Works
- User creates a Service with
type: LoadBalancer - MetalLB controller assigns an IP from the pool
- MetalLB speaker announces the IP via ARP on the local network
- External traffic to the IP is routed to the service
Troubleshooting
Check IP Pool Status
kubectl get ipaddresspool -n metallb-system
kubectl get l2advertisement -n metallb-system
Check Speaker Pods
kubectl get pods -n metallb-system -l component=speaker
kubectl logs -n metallb-system -l component=speaker
Common Issues
- No IPs available - Pool exhausted; expand the address range
- ARP not working - Check network allows ARP broadcasts
- Firewall blocking - Ensure firewalld/iptables allows traffic