Table of Contents
Install Kubernetes on Raspbian on a Raspberry Pi Cluster
Return to Install Kubernetes, Kubernetes topics, Kubernetes, Helm, Docker, Install Docker, Install Docker on Raspbian on a Raspberry Pi
Best Links
Instructions
Install Kubernetes on Raspbian on a Raspberry Pi Cluster
Kubernetes on (vanilla) Raspbian Lite
Yes - you can create a Kubernetes cluster with Raspberry Pis with the default Raspberry Pi operating system called Raspbian. This means you can carry on using all the tools and packages you're used to with the officially-supported OS.
This is part of a blog post Serverless Kubernetes home-lab with your Raspberry Pis written by Alex Ellis (https://blog.alexellis.io/serverless-kubernetes-on-raspberry-pi - 12 OCTOBER 2017 on raspberrypi, Raspberry PI, swarm, serverless, docker, arm, openfaas)
Copyright disclaimer: Please provide a link to the post and give attribution to the author if you plan to use this content in your own materials.
Update - k3s and docker
My current thinking is that k3s (https://github.com/teamserverless/k8s-on-raspbian#pick-k3s) from Rancher Labs is a better option than kubeadm to bootstrap a cluster. Whilst both create a compliant Kubernetes cluster, k3s uses fewer resources, is faster and doesn't run into some of the timing issues we've seen in the community with kubeadm.
You should also see my note on installing Docker on Raspbian Buster
Pre-reqs: To install and operate Kubernetes, you use only Raspberry Pi 3B, 3B+, or 4B I'm assuming you're using wired ethernet (Wi-Fi also works, but it's not recommended) Master node setup You can either follow the steps below, or use my flashing script which automates the below. The automated flashing script must be run on a Linux computer with an SD card writer or an RPi.
Flash with a Linux host Provision a Raspberry Pi SD card
Then run:
curl -sLSf https://gist.githubusercontent.com/alexellis/fdbc90de7691a1b9edb545c17da2d975/raw/125ad6eae27e40a235412c2b623285a089a08721/prep.sh ]] | profile static_eth0 static ip_address=192.168.0.100/24 static routers=192.168.0.1 static domain_name_servers=8.8.8.8 Hit Control + D. Change 100 for 101, 102, 103 etc. You may also need to make a reservation on your router's DHCP table so these addresses don't get given out to other devices on your network. Enable bridge-nf-call-iptables sudo sysctl net.bridge.bridge-nf-call-iptables=1 Install Docker This installs 17.12 or newer. curl -sSL get.docker.com | Add current user to docker group: sudo usermod pi -aG docker # Refresh groups newgrp docker Disable swap For Kubernetes 1.7 and onwards you will get an error if swap space is enabled. Turn off swap: $ sudo dphys-swapfile swapoff && \ sudo dphys-swapfile uninstall && \ sudo update-rc.d dphys-swapfile remove For Debian, also run: sudo systemctl disable dphys-swapfile This should now show no entries: $ sudo swapon --summary Edit /boot/cmdline.txt Add this text at the end of the line, but don't create any new lines: cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory Now reboot - do not skip this step. Add repo lists & install kubeadm $ curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | //apt.kubernetes.io/ kubernetes-xenial main" | //cloud.weave.works/k8s/net | base64 | test" <p><h1>test</h1></p> If you want to call the service from a remote machine such as your laptop then use the IP address of your Kubernetes master node and try the same again. Start up the Kubernetes dashboard The dashboard can be useful for visualising the state and health of your system, but it does require the equivalent of "root" in the cluster. If you want to proceed you should first run in a ClusterRole from the docs. echo -n 'apiVersion: rbac.authorization.k8s.io/v1beta1 kind: ClusterRoleBinding metadata: name: kubernetes-dashboard-head labels: k8s-app: kubernetes-dashboard-head roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: cluster-admin subjects: - kind: ServiceAccount name: kubernetes-dashboard-head namespace: kube-system' | [[Kubernetes documentation