What is MetalLB?
MetalLB is a network load balancer implementation tailored for bare-metal Kubernetes clusters. It bridges the gap between Kubernetes services and standard network protocols, enabling the use of external services without specialized hardware.
Key Features:
- Compatible with bare-metal clusters
- Supports both Layer 2 (ARP/NDP) and Layer 3 (BGP) networking
- Works with standard routers and switches
Note:
If you're using Azure VMs and vNets, Azure Load Balancers are required, so MetalLB isn't necessary/recomended. Stick to servicelb, but be aware of potential port collisions."
Installing or Upgrading MetalLB
Step 1: Disable Default servicelb (On Node machines)
Ensure the default k3s servicelb is disabled. If this wasn't done during cluster creation, disable it on each node manually:
Edit the k3s systemd service:
Add the flag --disable=servicelb to the ExecStart line:
Reload and restart the k3s service:
Step 2: Prepare configuration files (On user machine)
Download the files metallb.values.yml and metallb.basics.yml (attached to this article).
metallb.values.yml contains configuration values to start MetalLB. It is already filled with the values recommended by Collab.
metallb.basics.yml contains configurations to controll the IP Range that MetalLB should manage.
Open a CommandLine or PowerShell in the folder containing metallb.values.yml and metallb.basics.yml.
Step 3: Install MetalLB
Add the MetalLB Helm repository:
Install or upgrade MetalLB:
Step 4: Configure IP Address Range
Open the metallb.basics.yml file and edit the IP address range under spec > addresses. MetalLB supports CIDR notation or a specific range (e.g., 10.23.0.100-10.23.0.200).
Apply the configuration to your cluster:
Usage
Provisioning IPs for LoadBalancer Services
With MetalLB installed and configured, any Kubernetes service of type LoadBalancer will automatically be assigned an external IP address from the configured range. For manual IP assignment, use the LoadBalancerIP field in your service manifest.
Key Notes
IP Address Management:
MetalLB provisions IPs based on the range specified in your configuration. It can also accept manual IP assignments.Azure-specific Considerations:
For Azure VMs, MetalLB may be unnecessary due to the mandatory use of Azure Load Balancers. Stick to servicelb in such scenarios, and carefully manage port assignments to avoid collisions.CIDR or Range Support:
MetalLB supports both CIDR notation and specific ranges for IP addresses.
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article