[Raspberry Pi] k3sup install K3S Lightweight Kubernetes (K8S) on Raspberry Pi

k3sup 🚀 (said ‘ketchup’)

k3sup is a light-weight utility to get from zero to KUBECONFIG with k3s(Lightweight Kubernetes, the certified Kubernetes distribution built for IoT & Edge computing) on any local or remote VM. All you need is ssh access and the k3sup binary to get kubectl access immediately.

The tool is written in Go and is cross-compiled for Linux, Windows, MacOS and even on Raspberry Pi. and uses ssh to install k3s to a remote Linux host. You can also use it to join existing Linux hosts into a k3s cluster as agents. First, k3s is installed using the utility script from Rancher, along with a flag for your host’s public IP so that TLS works properly. The kubeconfig file on the server is then fetched and updated so that you can connect from your laptop using kubectl.

Installation

First install k3sup.

1
2
3
4
5
6
7
# macOS
$ brew install k3sup

# Or Raspberry Pi
$ wget https://github.com/alexellis/k3sup/releases/download/0.9.13/k3sup-armhf
$ chmod +x k3sup-armhf
$ sudo mv k3sup-armhf /usr/local/bin/k3sup

k3sup was developed to automate what can be a very manual and confusing process for many developers, who are already short on time. Once you’ve provisioned a VM with your favourite tooling, k3sup means you are only 60 seconds away from running kubectl get pods on your own computer.

Install K3S

k3sup can install k3s through SSH remote machine or local machine.

SSH Remote Machine

Install K3S on the remote machine(such as 192.168.1.110) through SSH.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
$ k3sup install --ip 192.168.1.110 --user pi
Running: k3sup install
2021/01/01 20:34:53 192.168.1.110
Public IP: 192.168.1.110
[INFO] Finding release for channel v1.19
[INFO] Using v1.19.5+k3s2 as release
[INFO] Downloading hash https://github.com/rancher/k3s/releases/download/v1.19.5+k3s2/sha256sum-arm.txt
[INFO] Downloading binary https://github.com/rancher/k3s/releases/download/v1.19.5+k3s2/k3s-armhf
[INFO] Verifying binary download
[INFO] Installing k3s to /usr/local/bin/k3s
[INFO] Creating /usr/local/bin/kubectl symlink to k3s
[INFO] Creating /usr/local/bin/crictl symlink to k3s
[INFO] Skipping /usr/local/bin/ctr symlink to k3s, command exists in PATH at /usr/bin/ctr
[INFO] Creating killall script /usr/local/bin/k3s-killall.sh
[INFO] Creating uninstall script /usr/local/bin/k3s-uninstall.sh
[INFO] env: Creating environment file /etc/systemd/system/k3s.service.env
[INFO] systemd: Creating service file /etc/systemd/system/k3s.service
[INFO] systemd: Enabling k3s unit
Created symlink /etc/systemd/system/multi-user.target.wants/k3s.service → /etc/systemd/system/k3s.service.
[INFO] systemd: Starting k3s
Result: [INFO] Finding release for channel v1.19
[INFO] Using v1.19.5+k3s2 as release
[INFO] Downloading hash https://github.com/rancher/k3s/releases/download/v1.19.5+k3s2/sha256sum-arm.txt
[INFO] Downloading binary https://github.com/rancher/k3s/releases/download/v1.19.5+k3s2/k3s-armhf
[INFO] Verifying binary download
[INFO] Installing k3s to /usr/local/bin/k3s
[INFO] Creating /usr/local/bin/kubectl symlink to k3s
[INFO] Creating /usr/local/bin/crictl symlink to k3s
[INFO] Skipping /usr/local/bin/ctr symlink to k3s, command exists in PATH at /usr/bin/ctr
[INFO] Creating killall script /usr/local/bin/k3s-killall.sh
[INFO] Creating uninstall script /usr/local/bin/k3s-uninstall.sh
[INFO] env: Creating environment file /etc/systemd/system/k3s.service.env
[INFO] systemd: Creating service file /etc/systemd/system/k3s.service
[INFO] systemd: Enabling k3s unit
[INFO] systemd: Starting k3s
Created symlink /etc/systemd/system/multi-user.target.wants/k3s.service → /etc/systemd/system/k3s.service.
Saving file to: /Users/cloudolife/kubeconfig

# Test your cluster with:
export KUBECONFIG=/Users/cloudolife/kubeconfig
kubectl config set-context default
kubectl get node -o wide

Or SSH into Raspberry Pi and run `kubectl’.

1
2
3
4
5
6
$ ssh [email protected]

# On Raspberry Pi
$ sudo kubectl get node -o wide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
raspberrypi Ready master 89m v1.19.5+k3s2 192.168.1.110 <none> Raspbian GNU/Linux 10 (buster) 5.4.79-v7+ containerd://1.4.3-k3s1
1
2
3
4
5
6
sudo kubectl get pods -A
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system metrics-server-7b4f8b595-4kdwb 1/1 Running 0 85m
kube-system coredns-66c464876b-nwkn5 1/1 Running 0 85m
kube-system local-path-provisioner-7ff9579c6-dzmrv 1/1 Running 0 85m
kube-system helm-install-traefik-xjgk4 1/1 Running 0 85m

Local Machine

If you are a local computer, you can bypass SSH with k3sup install --local.

1
2
# On Raspberry Pi
$ k3sup install --local

References

[1] alexellis/k3sup: bootstrap Kubernetes with k3s over SSH < 1 min 🚀 - https://github.com/alexellis/k3sup

[2] Deploying a highly-available K3s with K3sup - https://ma.ttias.be/deploying-highly-available-k3s-k3sup/

[3] K3s: Lightweight Kubernetes - https://k3s.io/

[4] k3s/README.md at master · k3s-io/k3s - https://github.com/k3s-io/k3s

[5] k3sup — Homebrew Formulae - https://formulae.brew.sh/formula/k3sup