Install k3s on a Raspberry PI

Views: 14
1 0
Read Time:3 Minute, 33 Second

In this article we are going through the steps needed to install k3s on a Raspberry PI and setup a single kubernetes cluster.

In this article:

What is K3s?

K3s is a lightweight certified kubernetes distribution built for IoT and Edge computing, created by Rancher Labs and is shipped as a single binary artifact. In other words is a minified kubernetes instance that we can easily deploy on low powered computer devices such as a Raspberry PI3. You can find an incredible amount of information here https://docs.k3s.io/

How to install K3s on the Raspberry

From the terminal we will have to run this command

curl -sfL https://get.k3s.io | sh -s - --write-kubeconfig-mode 644

Output of this command should be something similar to the one below

$ curl -sfL https://get.k3s.io | sh -s - --write-kubeconfig-mode 644
[INFO]  Finding release for channel stable
[INFO]  Using v1.25.6+k3s1 as release
[INFO]  Downloading hash https://github.com/k3s-io/k3s/releases/download/v1.25.6+k3s1/sha256sum-arm.txt
[INFO]  Downloading binary https://github.com/k3s-io/k3s/releases/download/v1.25.6+k3s1/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]  Creating /usr/local/bin/ctr symlink to k3s
[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

Failed to find memory cgroup

You might occur in an error message that is similar to the one below

[INFO] Failed to find memory cgroup, you may need to add “cgroup_memory=1 cgroup_enable=memory” to your linux cmdline (/boot/cmdline.txt on a Raspberry Pi)

To fix that issue you have to append the mentioned string cgroup_memory=1 cgroup_enable=memory to the /boot/cmdline.txt. It is important that there will be only that string added, nothing more (no carriage returns/newlines or commas). For doing that you can use vi/nano OR the command below, but please make sure you will do a backup of that file:

echo "$(cat /boot/cmdline.txt) cgroup_memory=1 cgroup_enable=memory" > ~/log-cmdline.txt

once verified that the output is the expected one (diff /boot/cmdline.txt ~/log-cmdline.txt) you can copy over that file

cp ~/log-cmdline.txt /boot/cmdline.txt

Now you should reboot your Raspberry PI

sudo reboot now

K3s now running

As the Raspberry PI is again up and running we can ssh into it or open the UI (depends on your taste) and run this command

$ sudo k3s server status
INFO[0000] Starting k3s v1.25.6+k3s1 (9176e03c)
INFO[0000] Configuring sqlite3 database connection pooling: maxIdleConns=2, maxOpenConns=0, connMaxLifetime=0s
INFO[0000] Configuring database table schema and indexes, this may take a moment...
INFO[0000] Database tables and indexes are up to date
INFO[0000] Kine available at unix://kine.sock
INFO[0001] Reconciling bootstrap data between datastore and disk
FATA[0001] starting kubernetes: preparing server: init cluster datastore and https: listen tcp :6443: bind: address already in use

and

$ kubectl get node
NAME     STATUS   ROLES                  AGE   VERSION
d3host   Ready    control-plane,master   14m   v1.25.6+k3s1

$ kubectl get pods -A
NAMESPACE     NAME                                      READY   STATUS              RESTARTS   AGE
kube-system   local-path-provisioner-79f67d76f8-5c6r7   0/1     ContainerCreating   0          6s
kube-system   helm-install-traefik-crd-tc4wr            0/1     ContainerCreating   0          6s
kube-system   helm-install-traefik-hmj6z                0/1     ContainerCreating   0          6s
kube-system   coredns-597584b69b-72kcw                  0/1     ContainerCreating   0          6s
kube-system   metrics-server-5f9f776df5-dfqfv           0/1     ContainerCreating   0          6s

Job Done! In the next articles we will show what you can do with k3s on the RasbperryPI

I hope you enjoyed and if so, please share and help us grow

Happy
Happy
0 %
Sad
Sad
0 %
Excited
Excited
0 %
Sleepy
Sleepy
0 %
Angry
Angry
0 %
Surprise
Surprise
0 %
Previous post Uninstall K3s: A Comprehensive Guide to Removing K3s from Your System
Next post Python for beginners
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x