1

I am doing a research project and our end goal is to essentially construct a kubernetes cluster using several Raspberry Pis. I've included the fact that we are using Raspberry Pis for reference, but I do not think it is quite relevant for my question.

I am quite new to networking, so please forgive me if I am asking a trivial question.

Recently, my task was to configure one of the Raspberry Pis (the master) to act as a network bridge between the internet and a local network where the other Pis (the workers) are connected to.

More specifically, I have the workers connected to an unmanaged switch which is connected to the master. All workers have static IPs. The master is connected to the internet via interface eth1 and it is connected to the network switch via eth0. My goal was to basically route internet traffic from eth0 to eth1 and vice versa.

I believe that I was successful in doing this. I used iptables to make the rules for this configuration. These are the commands I used:

$ sudo iptables -A FORWARD -i eth0 -o eth1 -j ACCEPT
$ sudo iptables -A FORWARD -i eth1 -o eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
$ sudo iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE

I enabled iPv4 forwarding on the master and configured the default gateway and DNS servers on the workers. I simply used Google's primary and secondary DNS servers and I used the eth0 IP address of the master as the default gateway for the workers. I believe this was successful since I was able to ping google, download kubernetes, and perform updates on the system using apt-get.

Now that I've set up the context of this network setup, my main question is in relation to how complete this setup is. I've been having issues with kubernetes trying to connect the workers to the master. Specifically, it's having trouble getting the default gateway. Here is the stdout when trying to join the server from a worker in case anyone has a better comprehension.

INFO[2020-04-12T14:43:40.167158119-04:00] Starting k3s agent v1.17.4+k3s1 (3eee8ac3)   
INFO[2020-04-12T14:43:40.168078475-04:00] module overlay was already loaded            
INFO[2020-04-12T14:43:40.168178317-04:00] module nf_conntrack was already loaded       
INFO[2020-04-12T14:43:40.168234827-04:00] module br_netfilter was already loaded       
INFO[2020-04-12T14:43:40.169668407-04:00] Running load balancer 127.0.0.1:43169 -> [red:6443] 
ERRO[2020-04-12T14:43:40.858464467-04:00] unable to select an IP from default routes.  
ERRO[2020-04-12T14:43:46.124906066-04:00] unable to select an IP from default routes.  

For reference, red is the hostname of the master and the IP is known by the worker as it is in /etc/hosts

I am sure that the hostname is known as I am able to do things like ssh pi@red.

I won't go too much in details on the kubernetes setup as it's not the main point of my question. I was able to get the cluster to work when the workers were directly connected to my wifi router, but now that I've configured it to use a network switch connected to the master, it's no longer working. So I am wondering if perhaps I am missing something with my configuration. I'm really stumped on this because I don't understand how I would be able to download things from the internet if there was some underlying issue.

I've seen tutorials online that use things like dnsmasq, but for my purposes, I have set a static IP for the workers, so I don't see the need for it if I am not using dhcp. Any help or insight would be greatly appreciated!

devrick
  • 11
  • 2
  • that's not a common usage you've here: you're using the master node as a router. But Kubernetes checks the iptables via kube-proxy every 5s (if my memory is good). It would be better to use one raspberry as a router and put all masters and workers node in the internal network – Kartoch Apr 21 '20 at 13:48

0 Answers0