In a cloud environment, exposing applications with LoadBalancer services is easy because the cloud provider automatically creates an external load balancer for you. On Bare Metal Kubernetes clusters, they don't work, and services stay pending. MetalLB Bare Metal load balancing fixes this by enabling service type as a load balancer without any cloud provider.
In this guide, you will learn to plan your IP ranges, configure Layer 2 and BGP modes, and test your setup with a sample application.
You can deploy MetalLB on PerLod Hosting high-performance bare metal servers for more stable networking and throughput.
Prerequisites and Network Planning for MetalLB Bare Metal Load Balancing
Before you start to deploy MetalLB, you should confirm a few cluster and network details.
Kubernetes 1.13+ with a CNI plugin that does not conflict with MetalLB, such as Calico, Flannel, Cilium, etc.
A bare metal cluster where the cloud load balancer integration is not available, like kubeadm, k3s, k0s, etc.
A dedicated pool of external IPs in your LAN or a separate subnet that MetalLB can assign to LoadBalancer services.
For example, if your LAN is 192.168.1.0/24, you might reserve 192.168.1.240–192.168.1.250 only for MetalLB.
Note: Do not assign MetalLB IPs to any physical hosts or DHCP pools.
MetalLB can be installed in several ways, including:
Apply upstream Kubernetes manifests directly.
Install via Helm using the official Helm repository.
Use Kustomize overlays for more custom deployments.
The manifest and Helm methods are the most common methods, which will be explained in this guide.
Method 1. Install MetalLB with Kubernetes Manifest
The easiest way to install MetalLB is with a single command that downloads official Kubernetes files. This method works on any cluster and sets up MetalLB's main parts, including:
The metallb-system namespace, if it is not precreated.
The MetalLB controller Deployment and speaker DaemonSet, responsible for assigning IPs and announcing them on the network.
CRDs such as IPAddressPool and L2Advertisement or BGP-related resources are used for configuration.
No additional tools are needed for this method; you only require kubectl.
Create MetalLB Namespace (Optional)
The first step is to create the MetalLB Namespace.
Some examples and older docs apply a separate namespace manifest first, but the current native manifest usually includes namespace creation.
If you want to create it, you can use the command below:
Bash
kubectlcreatenamespacemetallb-system
It tells the Kubernetes API server to create a logical namespace called metallb-system where all MetalLB resources will live.
Then, if you apply the native manifest, it will install the controller and speaker components and their CRDs.
Apply MetalLB Native Kubernetes Manifest
From the official website, use the latest version and apply the MetalLB manifest with the command below:
These commands show why a pod is failing as image pull error, permission, etc.
Method 2. Install MetalLB with Helm
Another method that you can use to install MetalLB is using Helm. Helm is recommended for production because it makes upgrades and customization easier.
Add MetalLB Helm Repository
You can use the command below to add the MetalLB Helm Repository, which registers the official MetalLB chart repository under the name metallb so Helm can fetch charts from it:
You should see EXTERNAL-IP populated with one of the IPs from the IP ranges after a few seconds.
Access the External IP from your LAN, and you must see the default Nginx page.
Bash
http://<EXTERNAL-IP>/
If the EXTERNAL-IP remains pending, check:
Bash
kubectlgetpods-nmetallb-system#MetalLB pods statuskubectldescribesvcnginx-lb#Events on the service for allocation errors
2. Configure MetalLB in BGP Mode
BGP mode scales better and integrates with routing on your firewall or router, but it requires BGP-capable hardware or software, for example, a router, FRR, or a firewall like pfSense or OPNsense.
Plan for BGP:
For a basic BGP configuration, you need:
An IP address of your router, for example, 10.0.0.1.
The router’s ASN, for example, 64501.
An ASN for MetalLB itself, for example, 64500.
An IP prefix (subnet) MetalLB will advertise, for example, 10.25.0.0/24.
This subnet should not be configured anywhere else; it will be announced dynamically by MetalLB and routed to your nodes.
Example BGP Configuration CRs:
A typical BGP setup includes an IPAddressPool, a BGPPeer, and a BGPAdvertisement. The older ConfigMap-based style might look like this:
Note: Newer versions of MetalLB prefer CRDs like BGPPeer and BGPAdvertisement instead of a single config ConfigMap.
For larger, routed environments, combine MetalLB with enterprise-grade dedicated servers to handle higher traffic and more BGP sessions.
Which MetalLB mode should we use? Layer 2 or BGP?
Layer 2 is simpler and works on almost any home or small office network, while BGP is more advanced and designed for larger, routed environments.
Here is a quick comparison to choose the right mode:
Feature
Layer 2 Mode
BGP Mode
Network requirement
Any Ethernet network, no special router.
BGP-capable router/firewall or software router.
How it works
One node advertises VIP via ARP/NDP.
Nodes announce VIPs as routes via BGP.
Load distribution
All traffic enters via one node, then kube-proxy is distributed.
Traffic can be balanced at the routing layer across nodes.
Complexity
Simple to set up (Pools + L2Advertisement).
More complex (ASNs, peers, prefixes).
Best for
Small/medium labs, simple homelab clusters.
Larger production clusters need advanced routing.
Conclusion
MetalLB provides cloud-style load balancing to bare metal Kubernetes by turning ordinary Services into reachable endpoints on your own network. With an IP plan and a few YAML objects, you can choose between a simple Layer 2 setup for homelabs or a powerful BGP configuration for routed environments.
We hope you enjoy the MetalLB Bare Metal load balancing setup guide.
Subscribe to our X and Facebook channels to get the latest articles and updates.
MetalLB gives you working LoadBalancer services on clusters that have no cloud provider. Instead of services staying in a pending state, MetalLB assigns real IPs from your network so you can reach apps directly.
No. For Layer 2 mode, you only need a normal Ethernet network and a free IP range. For BGP mode, you do need a BGP‑capable router, firewall, or software router.
Many users run MetalLB in production, but you should treat it like any core network component. Also, make sure your IP planning and routing are correct before going live.
No. MetalLB provides external IPs for Services. Ingress controllers like NGINX Ingress or Traefik still handle HTTP routing and host or path rules.
We use cookies to run PerLod and to understand how the site is used. You can accept everything, or open Manage to turn individual categories off. Cookie policy.