MetalLB is an open-source load balancer implementation designed specifically for bare-metal Kubernetes clusters. In bare-metal environments, traditional cloud-provider load balancers are not available, leaving a gap in Kubernetes' networking capabilities. MetalLB fills this gap by providing a network load balancer that integrates with standard network equipment, enabling external services on bare-metal clusters to function seamlessly.
* **Layer 2 Mode:** Operates at the data link layer, distributing traffic based on MAC addresses. * **BGP Mode:** Leverages the Border Gateway Protocol (BGP) to advertise service IPs to the broader network, enabling external access.
While MetalLB primarily relies on configuration through Kubernetes manifests, here's a simplified example of how to define an address pool:
```yaml apiVersion: metallb.io/v1beta1 kind: IPAddressPool metadata:
name: my-ip-pool namespace: metallb-systemspec:
addresses: - 192.168.1.200-192.168.1.250```
This configuration creates an IPAddressPool named “my-ip-pool” in the `metallb-system` namespace, allocating a range of IP addresses from 192.168.1.200 to 192.168.1.250 for MetalLB to assign to services.