Add Raspberry PI node to Kubernetes Cluster in 10 min
Goal
During some of the manipulation of the partition table of my SD card, I ended up screwing up both my SD card and my backup Win32DiskImage backup. Moreover if your SD card is 32G, it takes around 30 minute to restore from backup. Hence the idea to come up with a way to build more resiliency in the cluster. Recreating a node from scratch should not take more than 10 mn. The propose procedure is still rather long because I did not push enough yet what the HypriotOS team, aka build a default SD image where cloud-init does 100% of the initialization work.
Base OS
Flash HypriotOS to SD and reboot Pi.
Flash the SD Card with HypriotOS
Connect Pi through LAN (temporary).
Look for black-perl machine in DHCP
Connect to PI through LAN
ssh 192.168.1.xxx -l rpiuser
ls -lt
docker ps
Enable LAN or WLAN.
Check the IP address. Depending on PI3B or PI3B+, the WLAN network may be different.
ip a
iwconfig
sudo ip link set wlan0 up
sudo iwlist scan | grep ES
sudo iwlist scan | grep ED
wpa_passphrase <sommessid>
sudo vi sudo vi /etc/network/interfaces.d/wlan0
sudo ifup wlan0
Freeze your configuration
Cloud init is perfect for the first boot. Once the node is up, it can be challenging not to preserve the fine tuning done to the OS.
sudo apt-get remove --purge cloud-init
sudo apt-get autoremove
Update your Pi name
as root
sudo -i
vi /etc/hosts
vi /etc/hostname
I useally don’t touch the file. Domain most likely coming from your Internet router. I actually updated the settings on the router to have consistent naming on my PI networks.
vi /etc/resolv.conf
Install kubeadm
Firt access the kubemaster node and regenerate a token:
kubeadm token create
Back on the new node, as root
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" > /etc/apt/sources.list.d/kubernetes.list
apt-get update
apt-get install -y kubeadm
kubeadm join 192.168.1.95:6443 --token yyyyyy.xxxxxxxxxxxxxxxx --discovery-token-ca-cert-hash sha256:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Conclusion
- Will have to come back later and use cloud-init, create a clean & small SD image for Win32DiskImage
- Will have to create more advanced partition on the SD card.