Repository navigation
MetalLB Configuration
MetalLB is deployed in this Kubernetes cluster to provide network load balancing functionality for bare metal environments.
MetalLB allows you to create Kubernetes services of type LoadBalancer without requiring a cloud provider. It assigns real IP addresses to LoadBalancer services, making them accessible from your network.
The cluster has several IP address pools configured for different purposes:
File: manifests/metallb/IPAddressPool-ingress.yaml
apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
name: ingress-pool
spec:
addresses:
- 172.16.100.251/32This pool assigns a single IP address (172.16.100.251) dedicated to the Traefik ingress controller.
Additional pools are defined for specific services:
-
IPAddressPool-default.yaml: For general services -
IPAddressPool-mc.yaml: For Minecraft servers -
IPAddressPool-transmission.yaml: For the Transmission BitTorrent client
MetalLB is configured to use Layer 2 mode for announcing IP addresses:
File: manifests/metallb/L2Advertisement.yaml
apiVersion: metallb.io/v1beta1
kind: L2Advertisement
metadata:
name: default
spec:
ipAddressPools:
- default-pool
- ingress-pool
- mc-pool
- transmission-poolThis configuration advertises all defined IP pools using ARP (for IPv4) or NDP (for IPv6).
To use MetalLB effectively:
- Reserve IP Addresses: Ensure the IPs used in the address pools are excluded from your DHCP server's allocation range
- Network Connectivity: Ensure all Kubernetes nodes have layer 2 connectivity to the addresses in the pools
- Disable WiFi: WiFi interfaces often don't support the necessary protocols for MetalLB; use wired connections for nodes
When a service of type LoadBalancer is created:
- Kubernetes asks MetalLB for an external IP for the service
- MetalLB assigns an IP from the appropriate address pool
- MetalLB announces the IP address to the network
- In L2 mode, the node becomes the "owner" of the IP and responds to ARP requests
To create a service that uses MetalLB:
apiVersion: v1
kind: Service
metadata:
name: example-service
annotations:
metallb.universe.tf/address-pool: default-pool # Optional: specify a pool
spec:
type: LoadBalancer
ports:
- port: 80
targetPort: 8080
selector:
app: exampleCommon issues and solutions:
-
IP Address Conflicts: Ensure the IP addresses in your pools are not used elsewhere in your network
-
No Layer 2 Connectivity: Verify network connectivity between nodes and client devices
-
Check Speaker Pods: Ensure MetalLB speaker pods are running on all nodes
kubectl get pods -n metallb-system -o wide
-
Logs: Check logs for errors
kubectl logs -n metallb-system -l app=metallb