2 min to read
MetalLB - Load Balancer for Bare Metal Kubernetes Clusters
A comprehensive guide to implementing MetalLB in bare metal environments

Overview
While cloud platforms like AWS, GCP, and Azure provide built-in load balancers for Kubernetes clusters, bare metal environments require additional modules for load balancing functionality.
Today, we’ll explore MetalLB, an open-source solution that brings load balancer implementation to bare metal Kubernetes clusters.
🔑 What is MetalLB?
MetalLB (Metal Load Balancer) is designed to provide network load balancing functionality in environments where cloud providers’ load balancers aren’t available.
It uses standard routing protocols to provide load balancer services:
- ARP (IPv4)/NDP (IPv6) for Layer 2 mode
- BGP for Layer 3 mode
- Creates speaker pods as DaemonSets to propagate External IPs
Operating Modes
Layer 2 Mode
- One speaker pod becomes the leader and handles service traffic
- Uses host network mode (“NetworkMode”: “host”)
- Leader broadcasts ownership of External IP using ARP (GARP)
- Automatic failover if leader node fails
- Uses Hashicorp’s memberlist for membership and failure detection
- Simple configuration
- No special network configuration required
- Automatic failover
- Single-node bottleneck for service traffic
BGP Mode
- Speaker pods run BGP to advertise service information
- Supports IP address (32-bit) advertisement
- Configurable BGP communities and local preferences
- ECMP routing for load distribution
- Typically uses 5-tuple based routing (protocol, source/destination IP, source/destination port)
- Better scalability with ECMP support
- True load balancing across multiple nodes
- More flexible routing options
- Advanced traffic engineering capabilities
- Better integration with existing network infrastructure
Prerequisites
For IPVS mode, enable strictARP:
Install with Helm
# Add MetalLB helm repo
helm repo add metallb https://metallb.github.io/metallb
# Install MetalLB
helm install metallb metallb/metallb -n metallb-system --create-namespace
Install By Manifests
- Install via Manifest. However, it seems that the native of the file contains all the resources.
- Therefore, it seems good to look at the github of MetalLB and install the necessary resources.
# Install MetalLB
kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/main/config/manifests/metallb-native.yaml
Configure MetalLB
Check ipaddresspool
# Check validatingwebhookconfigurations
kubectl get validatingwebhookconfigurations
# Delete validatingwebhookconfigurations
kubectl delete validatingwebhookconfigurations metallb-webhook-configuration
# Check validatingwebhookconfigurations
kubectl get validatingwebhookconfigurations
# Apply metallb-config.yaml
k apply -f metallb-config.yaml -n metallb-system
# Check ipaddresspool
kubectl describe ipaddresspool.metallb.io --namespace metallb-system
Comments