This part covers adding a load-balancer to our raspberrypi4 cluster.
When you want to use kubernetes in your home environment, you’ll have the problem of having one public-ip and three raspberrypi nodes which form the kubernetes cluster. How can you access your cluster from the outside?
The solution is to use an service which is called load-balancer which acts as single access-point to your cluster and automaticly balance traffic between the three nodes.
One possible solution in the kubernetes ecosystem is using metallb.
kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.11.0/manifests/namespace.yaml
kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.11.0/manifests/metallb.yaml
apiVersion: v1
kind: ConfigMap
metadata:
namespace: metallb-system
name: config
data:
config: |
address-pools:
- name: default
protocol: layer2
addresses:
- 192.168.2.20-192.168.2.39 # IP-Range
This yaml-file of type ConfigMap tells metallb how to work. The important part is the IP-Range, which should match your routers IP-Range outside of the DHCP.
This prevents your router assigning metallb ips to your home-network devices.
So if your routers DHCP-Range is 192.168.2.1–192.168.2.100 you can use 192.168.2.101–192.168.2.103 as your metallb range.
Apply configuration
kubectl apply -f address-pool.yaml
Check if services are up and running with:
kubectl get pods -n metallb-system -o wide
If everything works fine it will like this:
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
metallb-controller-5488f4c94b-9k7kt 1/1 Running 1 (10d ago) 40d 10.42.1.73 kube2 <none> <none>
metallb-speaker-msdrl 1/1 Running 1 (10d ago) 40d 192.168.2.1 kube1 <none> <none>
metallb-speaker-wtbrf 1/1 Running 1 (10d ago) 40d 192.168.2.2 kube2 <none> <none>
metallb-speaker-xw6rx 1/1 Running 2 (10d ago) 40d 192.168.2.3 kube3 <none> <none>
The load-balancer is not so useful alone but in the next part we install an ingress controller to route traffic to our services.