Installing MetalLB

20 Dec 2021 20:55 kubernetes raspberry-pi metallb

Installation with Helm, per

Add the repo

helm repo add metallb

Create the values file

My home network is 192.168.28.x, my DHCP server allocates .100 and up, so we’ll use a pool of addresses outside that range.

# values.yaml
   - name: default
     protocol: layer2

Note that you don’t need a ConfigMap (i.e. no values.yaml) since 0.13.x; you can use CRDs to define the configuration.

Run the installation

helm --namespace metallb-system \
    install --create-namespace \
    metallb metallb/metallb -f values.yaml

To upgrade later:

helm --namespace metallb-system upgrade metallb metallb/metallb

Does it work?

$ kubectl create deployment nginx --image=nginx

$ kubectl expose deployment nginx --type=LoadBalancer --port 80

$ kubectl get services
NAME         TYPE           CLUSTER-IP      EXTERNAL-IP     PORT(S)        AGE
kubernetes   ClusterIP       <none>          443/TCP        5h53m
nginx        LoadBalancer   80:32580/TCP   117s

$ kubectl scale deployment --replicas=3 nginx

I forgot to disable Klipper, the K3s-provided load balancer. It doesn’t seem to do any harm, but I’ll deal with that later.