MetalLB - Load Balancer for Bare Metal Kubernetes Clusters

A comprehensive guide to implementing MetalLB in bare metal environments

Featured image

Image Reference



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:


Operating Modes

Layer 2 Mode

Key Features of Layer 2 Mode:
  • Simple configuration
  • No special network configuration required
  • Automatic failover
  • Single-node bottleneck for service traffic

BGP Mode

Key Features of BGP Mode:
  • 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 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



References