Installing MetalLB with Helm¶
Now, let's take our homelab to the next level by setting up MetalLB, a load balancer for your Kubernetes cluster. MetalLB allows you to use external IP addresses from your network to load balance traffic to services in your cluster.
Prerequisites¶
Before we proceed, ensure you have the following in place:
- A functioning Kubernetes cluster with K3s, which includes at least one master node and one or more worker nodes.
- Helm, the package manager for Kubernetes, installed on your master node.
- SSH access to your master node.
Add MetalLB Helm Repository¶
I'll begin by adding the MetalLB Helm chart repository to Helm. This repository contains the MetalLB Helm chart, making it easy to install.
I'm now all set to install MetalLB.
Configure and Install MetalLB¶
MetalLB requires a configuration to specify the IP address range it can use for load balancing. Here's a basic example of a MetalLB configuration:
apiVersion: v1
kind: ConfigMap
metadata:
namespace: metallb-system
name: config
data:
config: |
address-pools:
- name: default
protocol: layer2
addresses:
- <start_ip>-<end_ip>
- Replace
<start_ip>
and<end_ip>
with the range of IP addresses you want to allocate for load balancing. Make sure these IPs are available and not in use within your local network.
Save the configuration to a file, for example, metallb-config.yaml
.
Now, install MetalLB with Helm, using the configuration you just created:
helm install metallb metallb/metallb -n metallb-system --create-namespace --values metallb-config.yaml
This command installs MetalLB into the metallb-system
namespace, ensuring that MetalLB has its own namespace. The configuration file is provided via the -f
flag.
Verify MetalLB Installation¶
To check that MetalLB has been successfully installed and is running, I'll use the following command:
This command should display MetalLB's controller and speaker pods in the metallb-system
namespace, indicating that MetalLB is up and running.
With MetalLB installed, I now have a load balancer for my homelab Kubernetes cluster, allowing me to expose services using external IP addresses. This is a great addition for projects that require external access to applications running in my homelab.
Also notice that the Traefik ingress automatically now get's an ip address from the pool assigned. Here you can route any incoming traffik within you network to for using as ingress.