Blog    Bookmark    Note    Photo    Password Manager    About Me    Settings    Sign out

Build Kubernetes cluster on Raspberry Pi 3 b+

A tutorial on how to build Kubernetes cluster on Raspberry Pi can be found here. However, there were problems when I follow it, possibly because it is little outdated. The solutions can be found in the comments of that tutorial. This post is a summary of the solution.

Master setup

Change hostname using raspi-config utility.

Set a staic IP address. I use WiFi and didn't set static address. The ip addresses of nodes usually don't change after reboot if the router is the same one used before the reboot.

Install Docker

$ curl -sSL | sh && \
sudo usermod pi -aG docker

Turn off swap:

$ sudo dphys-swapfile swapoff && \
  sudo dphys-swapfile uninstall && \
  sudo update-rc.d dphys-swapfile remove

Edit /boot/cmdline.txt. Add the following line to the end of the line, but don't create any new lines:

cgroup_enable=cpuset cgroup_enable=memory cgroup_memory=1


sudo reboot

Install v1.9.7-00

$ curl -s | sudo apt-key add - && \
echo "deb kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list && \
sudo apt-get update -q && \
sudo apt-get install -qy kubelet=1.9.7-00 kubectl=1.9.7-00 kubeadm=1.9.7-00

Install weave 1.6

kubectl apply -f

Initialize your master node

$sudo kubeadm init --token-ttl=0 --apiserver-advertise-address= --ignore-preflight-errors=ALL

After the init is complete run the snippet:

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

The above command outputs a toekn which will be used for nodes to join the master. save the token somewhere. The token will be expired after 24 hours.

Join other nodes:

Change hostname using raspi-config

Join the cluster:

$ sudo kubeadm join --token 1fd0d8.67e7083ed7ec08f3

Check the nodes on the cluster:

$ kubectl get nodes



Write a comment

Captcha image


Type the number you see in the image above: