2

I'm fiddling around with my RPI cluster that I've setup using Kubeadm and I want to make LoadBalancers able to work on the cluster. The IPs for the nodes are static and set to the range of 192.168.1.100-192.168.1.103 for the master and worker nodes.

I've installed the Metallb using the offical site docs.

This is my configmap for Metallb:

apiVersion: v1
kind: ConfigMap
metadata:
  namespace: metallb-system
  name: config
data:
  config: |
    address-pools:
    - name: default
      protocol: layer2
      addresses:
      - 192.168.2.240-192.168.2.250

From what I've understood you're supposed to give the loadbalancers a range outside of the DHCP range of the router? But even changing the addresses range to something like 192.168.1.200-192.168.1.240 doesn't change the results I'm getting.

The DHCP settings for my router.

DHCP settings

K8s node info

NAME            STATUS   ROLES    AGE     VERSION   INTERNAL-IP     EXTERNAL-IP   OS-IMAGE                         KERNEL-VERSION   CONTAINER-RUNTIME
k8s-master      Ready    master   5d15h   v1.17.4   192.168.1.100   <none>        Raspbian GNU/Linux 10 (buster)   4.19.97-v7l+     docker://19.3.8
k8s-worker-01   Ready    worker   5d15h   v1.17.4   192.168.1.101   <none>        Raspbian GNU/Linux 10 (buster)   4.19.97-v7+      docker://19.3.8
k8s-worker-02   Ready    worker   4d14h   v1.17.4   192.168.1.102   <none>        Raspbian GNU/Linux 10 (buster)   4.19.97-v7+      docker://19.3.8
k8s-worker-03   Ready    worker   4d14h   v1.17.4   192.168.1.103   <none>        Raspbian GNU/Linux 10 (buster)   4.19.97-v7+      docker://19.3.8

Then I try to setup a small nginx deployment

kubectl run nginx --image=nginx 
kubectl expose deploy nginx --port=80 --type=LoadBalancer

Running kubectl get svc returns:

NAME         TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)          AGE
kubernetes   ClusterIP      10.96.0.1        <none>        443/TCP          5d15h
nginx        LoadBalancer   10.96.53.50      <pending>     80:31253/TCP     4s

This is where I'm stuck now. I don't seem to be able to get a LoadBalancer to work with this setup and I'm not really sure where I'm going wrong.

Metallb output

NAME                              READY   STATUS    RESTARTS   AGE
pod/controller-65895b47d4-q25b8   1/1     Running   0          68m
pod/speaker-bnkpq                 1/1     Running   0          68m
pod/speaker-d56zg                 1/1     Running   0          68m
pod/speaker-h9vpr                 1/1     Running   0          68m
pod/speaker-qsl6f                 1/1     Running   0          68m

NAME                     DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR                 AGE
daemonset.apps/speaker   4         4         4       4            4           beta.kubernetes.io/os=linux   68m

NAME                         READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/controller   1/1     1            1           68m

NAME                                    DESIRED   CURRENT   READY   AGE
replicaset.apps/controller-65895b47d4   1         1         1       68m
Gurkang
  • 155
  • 1
  • 3
  • 16
  • Is MetalLB itself actually running? – coderanger Mar 22 '20 at 07:27
  • @coderanger added output of `metallb get all -n metallb-system` – Gurkang Mar 22 '20 at 07:32
  • can you double-check if your configmap is actually applied? using `kubectl get configmap -n metallb-system`? also, can you describe the service and add the output? `kubectl describe svc nginx`? Also, metallb controller logs can be helpful: `kubectl -n metallb-system logs controller-65895b47d4-q25b8` – Utku Özdemir Mar 22 '20 at 16:26

2 Answers2

3

MetalLB layer2 mode doesn't receive broadcast packets unless promiscuous mode is enabled.

Try below

sudo ifconfig wlan0 promisc

Add a Crontab to run each start up so you will not lose this change on restart.

    1. sudo crontab -e
    2. Add this line at the end of the file 
         @reboot sudo ifconfig wlan0 promisc
marvelTracker
  • 4,691
  • 3
  • 37
  • 49
  • I am using ubuntu 64bit 20.10 on rpi 4. While after executing this command `sudo ifconfig wlan0 promisc`, the metallb is working until rpi is rebooted. How can you persist this command so that it survives the reboot? – Muhammad Arslan Akhtar Dec 16 '20 at 01:55
  • This is the only solution that worked for me - now I can access the Load Balancer Ingress IP from outside of the cluster. Thank you!! – Anton Petrov Feb 11 '23 at 21:25
0

In my setup with MetalLB, Cilium and HAProxy Ingress Controller I'd to change externalTrafficPolicy from Local to Cluster

kubectl --namespace ingress-controller patch svc haproxy-ingress \
 -p '{"spec":{"externalTrafficPolicy":"Cluster"}}'
Oleg Neumyvakin
  • 9,706
  • 3
  • 58
  • 62