2 minutes
Setting up MetalLB on your Raspberry Kubernetes Cluster
After lurking for a long time around this topic i pulled the trigger a couple of days ago and shopped the components to build a raspberry pi powered kubernetes cluster at home. The main purpose is to learn new things and get my hands dirty on kubernetes and the project attached to the cloud native computing foundation.
Setting this up was very easy thanks to k3sup and arkade. But i was lacking a loadbalancer support. In cloud environments this is where the infrastructure provided by the cloud provider kicks in.
This is where MetalLB can help you. MetalLB provides a LoadBalancer and maps this to an definded IP Range so that you can reach your Containers over the Network.
I assume that you have a Kubernetes Cluster up and running and that your kubectl command is working.
Lets create a local directory in which we can download the needed .yaml files. In my case i have a kubernetes directory inside of my homedirectory.
cd ~/kubernetes
mkdir metallb
cd metallb
wget https://raw.githubusercontent.com/metallb/metallb/v0.9.6/manifests/namespace.yaml
wget https://raw.githubusercontent.com/metallb/metallb/v0.9.6/manifests/metallb.yaml
This files will be used to deploy MetalLB on your Kubernetes Cluster. But we will need to define a pool of ip addresses which can be used by MetalLB. Lets create a file config.yaml inside our metallb directory with the following content (adjust the ip pool as needed)
apiVersion: v1
kind: ConfigMap
metadata:
namespace: metallb-system
name: config
data:
config: |
address-pools:
- name: default
protocol: layer2
addresses:
- 192.168.1.50-192.168.1.60
We have now everything we need to deploy MetalLB
kubectl apply -f namespace.yaml
kubectl apply -f metallb.yaml
kubectl create secret generic -n metallb-system memberlist --from-literal=secretkey="$(openssl rand -base64 128)"
kubectl apply -f config.yaml
You can check the status of your Pods
kubectl get pods -n metallb-system
NAME READY STATUS RESTARTS AGE
controller-64f86798cc-79574 1/1 Running 0 5h44m
speaker-wfzwc 1/1 Running 0 5h44m
speaker-gjm88 1/1 Running 0 5h44m
speaker-l2z7r 1/1 Running 0 5h44m
speaker-5fm5v 1/1 Running 0 5h44m
And your Services with a type of LoadBalancer should have been assigned a working External-IP now:
kubectl get svc --all-namespaces | grep LoadBalancer
kube-system traefik LoadBalancer 10.43.154.37 192.168.1.50 80:31596/TCP,443:31489/TCP 18h
openfaas gateway-external LoadBalancer 10.43.40.74 192.168.1.15 8080:31461/TCP 17h
thanks for reading… :)
Bash Linux Kubernetes Raspberry pi Networking
357 Words
2021-03-04 14:32 (Last updated: 2021-03-24 12:01)
646497e @ 2021-03-24