OpenWrt Router on Pi 3

- 3 mins read

openwrt-on-raspberry-pi-3

By running OpenWrt Router on Raspberry Pi 3, you will be able to customize the device to suit your application usage


OpenWrt Router for Raspberry

(Total Setup Time: 20 mins)

In this guide, I will config OpenWrt as router on Raspberry Pi 3. The Wireless LAN (wlan0) is connected to home network while the LAN interface (eth0) is connected to the Kubernetes Cluster.

Preparing OpenWrt

(10 mins)

First, you may choose the Raspberry Pi image that matches your Pi. This is the downloaded image for my 4GB SD card on the Raspberry Pi 3 Model B.

Second, insert the SD card and boot up your Raspberry Pi. The default root password is empty.

openwrt-login


Third, from System > Administrator and change your router password.

openwrt-change-router-password


Installing OpenWrt

(5 mins)

First, navigate to System > LED configuration and customize the Raspberry Pi LED to your preferences.

openwrt-led-configuration


Second, from Network > Wireless, click on the Scan button and Join Network.

openwrt-generic-wireless


Third, moving on to Network > Interfaces, click on the Edit button for the LAN for configuring the interface.

openwrt-interfaces


Fourth, navigate to Network > DHCP and DNS > Static Leases, click on the Add button to add the Kubernetes master node.

openwrt-dns


Lastly, save all your settings and perform a reboot. You may go to System > Backup / Flash Firmware for a local backup copy.

Reconfiguring Kubernetes Cluster

(5 mins)

Because of the change in IP address, all my previous Kubernetes cluster settings are gone!

First, with thanks to the post from valerius257, these are the steps for restoring:

systemctl stop kubelet docker

cd /etc/
sudo mv kubernetes kubernetes-backup
sudo mv /var/lib/kubelet /var/lib/kubelet-backup
sudo mkdir -p kubernetes
sudo cp -r kubernetes-backup/pki kubernetes
sudo rm kubernetes/pki/{apiserver.*,etcd/peer.*}

systemctl start docker

sudo kubeadm init --ignore-preflight-errors=DirAvailable--var-lib-etcd

kubeadm-reinit


Second, start using the cluster by following the commands:

mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

# Join each worker nodes as root
sudo kubeadm join 192.168.100.100:6443 --token iu0gjx.lc07ou5eruk5d5sf \
    --discovery-token-ca-cert-hash sha256:752ee2428cc151770a4f7cf45a9595f8608440988f853bd4ee6c0a1a174b310b

Third, re-initializes all previous worker nodes.

# Performs a reset on each node
sudo kubeadm reset

# Re-joins the master node on each node
sudo kubeadm join 192.168.100.100:6443 --token 6o88ge.uxq1g9hk4kmd9rhx \
    --discovery-token-ca-cert-hash sha256:1dc568d05f2be9260091f758207f236b87282f55ee72b3cb09dfb1639ee28c4c
	
# From master node, checks if the worker node joins successfully
kubectl get nodes

kubectl-nodes-ready


Because 1 node(s) had taint {node-role.kubernetes.io/master: }, my Jenkins fails to work. This error is fixed by running this command:

kubectl taint nodes master1k8s node-role.kubernetes.io/master:NoSchedule

Troubleshooting

Missing Wireless Menu for OpenWrt on Raspberry Pi 2

This is the downloaded image for my Raspberry Pi 2 Model B+. I tried using my USB Wi-Pi (OYR-COMFAST88) and this /etc/config/wireless setting, but failed.

config wifi-device 'radio0'
        option type 'mac80211'
        option channel '11'
        option hwmode '11g'
        option path 'platform/soc/3f300000.mmc/mmc_host/mmc1/mmc1:0001/mmc1:0001:1'
        option htmode 'HT20'
        option disabled '1'

config wifi-iface 'default_radio0'
        option device 'radio0'
        option network 'lan'
        option mode 'ap'
        option ssid 'OpenWrt'
        option encryption 'none'