Home Kubernetes Cluster on Raspberry Pi
Post
Cancel

Kubernetes Cluster on Raspberry Pi

Preperation

Prep all the Raspberry Pis with the lite non desktop 64bit version of Raspberry Pi OS. Be shure to set a unique hostname for each Raspberry Pi.

Install k3s

ssh into the first node which will become the master and switch to root:

1
sudo su -

Update and install tailscale

1
apt update && apt upgrade -y && curl -fsSL https://tailscale.com/install.sh | sh && tailscale up --ssh

Modify the cmdline.txt file and reboot:

1
2
sed -i '1s/^/cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory /' /boot/firmware/cmdline.txt
reboot

After logging back in, install k3s and verify the installation:

1
2
curl -sfL https://get.k3s.io | sh -
kubectl get nodes

Join the other nodes

Repeat the install process for each node and extract the token from your master node.

1
cat /var/lib/rancher/k3s/server/node-token

ssh into the other nodes and join the cluster using the token and hostname from the master node:

1
curl -sfL https://get.k3s.io | K3S_URL=https://hostname:6443 K3S_TOKEN=token_from_earlier sh -

Install Portainer

If you want to install portainer on your cluster, run the following commands on your master node:

1
kubectl apply -n portainer -f https://raw.githubusercontent.com/portainer/k8s/master/deploy/manifests/portainer/portainer.yaml

Portainer is avalible at http://master:30777

If you want to controll the cluster from a existing Portainer instance install Portainer Agent:

1
kubectl apply -f https://downloads.portainer.io/ce2-19/portainer-agent-k8s-lb.yaml

Now you can add the cluster to your existing Portainer instance.
source

This post is licensed under CC BY 4.0 by the author.