Wednesday, May 27, 2020

Kubernetes on raspberry pi

There are quite a few articles (referenced at the bottom) which I used and here is the notes of my own installation.

The main difference is I do not want to interfere with the DHCP so I created a VLAN on the raspberry pi, so I can have the static IP and still be able to plug my pi into any network to get an IP address.

The other thing is I want to reduce the amount of devices on at the same time, so limiting to 1 node.

1. Install PI and setup networking.

I wanted to keep the DHCP and create a new VLAN for cluster communication so I can move the pi around without having to reconfigure the network.

$ sudo apt install vlan

add these lines to a new file /etc/network/interfaces.d/vlan

auto eth0.10
iface eth0.10 inet manual
  vlan-raw-device eth0

Add this to the end of the file /etc/dhcpcd.conf

interface eth0.10
static ip_address=
static routers=

As there are 2 hosts. change the IP addresses on the 2nd host.

interface eth0.10
static ip_address=

Next to edit the hosts file on both servers so that each node can find each other node1 node2

2. Install pre-requisites

  • Install Docker
$ curl -fsSL -o
$ sudo sh
$ sudo usermod -aG docker pi

  • Remove swapfile
$ sudo dphys-swapfile swapoff 
$ sudo dphys-swapfile uninstall
$ sudo update-rc.d dphys-swapfile remove
$ sudo systemctl disable dphys-swapfile.service

2. Install Kubernetes

$ sudo echo "deb kubernetes-xenial main"  | sudo tee /etc/apt/sources.list.d/kubernetes.list/etc/apt/sources.list.d/kubernetes.list
$ sudo curl -s | apt-key add -
$ sudo apt-get update
$ sudo apt-get install -y kubeadm

3. Configure Master

On the master node, e.g. node1

$ sudo kubeadm config images pull
$ sudo kubeadm init --token-ttl=0 --apiserver-advertise-address --control-plane-endpoint node1 --node-name node1 --pod-network-cidr

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

4. Add additional nodes and test

login to node2

$ sudo sudo kubeadm join node1:6443 --token \
    --discovery-token-ca-cert-hash   \
    --apiserver-advertise-address \
    --node-name node2 \

$ mkdir -p $HOME/.kube
$ scp node1:/home/pi/.kube/config /home/pi/.kube/config

$ kubectl get nodes

node1   NotReady   master   20h   v1.18.2
node2   Ready         20h   v1.18.2

5. Install a CNI and load balancer

  • Weave CNI
$ kubectl apply -f "$(kubectl version | base64 | tr -d '\n')"

  • MetalLB
kubectl apply -f
kubectl apply -f
# On first install only
kubectl create secret generic -n metallb-system memberlist --from-literal=secretkey="$(openssl rand -base64 128)"

6. Install Helm package manager 

$ curl -fsSL -o
$ chmod 700
$ ./
$ helm repo add bitnami
$ helm repo update

$ helm install bitnami/jenkins --generate-name

7. Enable this so that kubenetes starts after reboot.

$ sudo systemctl enable kubelet

No comments:

dead pi

Well, I guess it has to happen at some point. the home automation raspberry pi has died. Much to do with the stupid Strontium mini SD card. ...