MetalLB — Load Balancer Implementation for Bare-Metal Kubernetes
MetalLB is a network load-balancer implementation for bare-metal Kubernetes clusters using standard routing protocols (Layer 2 ARP/NDP or BGP). It lets Services of type LoadBalancer work on clusters that do not run on a cloud provider.
What it is
MetalLB is a load-balancer implementation for bare-metal Kubernetes clusters. In cloud environments, Services of type LoadBalancer are automatically provisioned by the cloud provider. On bare-metal clusters, this service type remains in a perpetual 'Pending' state because no external load balancer exists. MetalLB fills this gap by using standard routing protocols (Layer 2 ARP/NDP or BGP) to assign external IP addresses to Kubernetes Services.
This tool targets teams running Kubernetes on their own hardware, in colocation facilities, or on-premise data centers. Anyone who needs external traffic routing to Kubernetes Services without a cloud provider benefits from MetalLB.
How it saves time or tokens
Without MetalLB, bare-metal Kubernetes operators must manually configure NodePort services, external HAProxy instances, or custom iptables rules. MetalLB automates this entirely: declare a Service of type LoadBalancer, and MetalLB assigns an IP and advertises it. This eliminates hours of manual network configuration per service.
How to use
- Install MetalLB via kubectl apply or Helm into your cluster
- Configure an IP address pool that MetalLB can assign to Services
- Create a Service of type LoadBalancer; MetalLB assigns an IP automatically
Example
# Install MetalLB
# kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.14.8/config/manifests/metallb-native.yaml
# Configure IP pool
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
Related on TokRepo
- DevOps tools — Explore Kubernetes networking and infrastructure tools
- Self-hosted tools — Browse self-hosted infrastructure components
Common pitfalls
- Layer 2 mode has a single-node failover limitation; only one node handles traffic for each IP at a time
- BGP mode requires a compatible router and proper peering configuration; misconfigured BGP drops all traffic
- IP address pools must not overlap with your DHCP range or other network allocations
Frequently Asked Questions
Layer 2 mode uses ARP/NDP to announce IPs on the local network segment. It is simpler to set up but limits failover to one node per IP. BGP mode advertises routes to upstream routers, enabling true load distribution across nodes but requiring BGP-capable network gear.
Yes. MetalLB works with vanilla Kubernetes, k3s, kubeadm, RKE, and other distributions. It requires Kubernetes 1.13 or later and a cluster network that allows the chosen protocol (Layer 2 or BGP).
Yes. Layer 2 mode is ideal for home labs because it needs no special network equipment. Just reserve a range of IPs on your local subnet and configure MetalLB to use them.
One node holds the IP and responds to ARP requests. If that node goes down, another node takes over the IP. Failover typically takes a few seconds as ARP caches expire and refresh.
Yes. MetalLB is widely used in production bare-metal Kubernetes clusters. BGP mode is preferred for production because it offers better load distribution and faster failover than Layer 2 mode.
Citations (3)
- MetalLB GitHub— Load balancer for bare-metal Kubernetes using Layer 2 and BGP
- MetalLB Documentation— Layer 2 and BGP protocol support for IP address assignment
- Kubernetes Documentation— Kubernetes LoadBalancer Service support for bare-metal clusters
Related on TokRepo
Discussion
Related Assets
Heimdall — Application Dashboard for Your Server
Heimdall is an elegant self-hosted application dashboard that organizes all your web services and apps into a single, customizable start page with enhanced tile features.
Healthchecks — Cron Job Monitoring with Smart Alerts
Healthchecks is a self-hosted cron job and scheduled task monitor that alerts you when your periodic jobs fail to run on time.
Shiori — Simple Self-Hosted Bookmark Manager
Shiori is a lightweight self-hosted bookmark manager written in Go with full-text search, archiving, and a clean web interface for organizing your saved links.