Why?
My motivation for using Kubernetes to manage Pi-hole and other services is to enable Pi-hole to run on any node within the cluster, which could result in IP changes. Additionally, I may want to create multiple instances of Pi-hole in the future to enhance redundancy. To achieve this, I need to place Pi-hole behind a load balancer.
By default, Kubernetes does not include load balancer provisioners. Therefore, when operating a Kubernetes cluster on my Raspberry Pi setup, I must provide a provisioner. Although k3s comes with klipper-lb pre-installed, its downside is that the load balancer IP is tied to the node.
Metallb offers a solution by allowing me to designate a reserved IP range for load balancers. It is simple and efficient, making it suitable for home use.
Prerequisite
Disable klipper-lb with --disable servicelb
flag
|
|
Installation
|
|
Reference: the official guide
IP Address Pool
At here I defined an IP address pool local-pool
with address range 192.168.10.240
to 192.168.10.250
.
|
|
Then advertise the pool with the simplest layer 2 mode (corresponding to layer 3 in OSI model).
|
|
That’s it.
Example
Here’s an example of creating a TCP and a UDP load balancers sharing the same IP:
|
|