Skip to main content

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

ComponentPurpose
metallb-controllerIP address allocation and management
metallb-speakerARP announcer (runs as DaemonSet)

How It Works

  1. User creates a Service with type: LoadBalancer
  2. MetalLB controller assigns an IP from the pool
  3. MetalLB speaker announces the IP via ARP on the local network
  4. 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

  1. No IPs available - Pool exhausted; expand the address range
  2. ARP not working - Check network allows ARP broadcasts
  3. Firewall blocking - Ensure firewalld/iptables allows traffic