Installing k3s Kubernetes on Raspberry Pi (Raspbian)

kubernetes Raspberry-Pi
2020-11-23 16:58 (4 years ago) ytyng

Installing k3s Kubernetes on Raspberry Pi (Raspbian)

We will install k3s in Docker mode.

1. Installing Docker

According to the Docker documentation, it is recommended to use the convenience script for Raspbian. So, we will follow that recommendation.

https://docs.docker.com/engine/install/debian/

curl -fsSL https://get.docker.com -o /tmp/get-docker.sh
sudo sh /tmp/get-docker.sh



This will install Docker.

If you skip this step and try to use Rancher's script or manually add the GPG key, you might find yourself asking questions like "Is the CPU armhf or arm64?" or "Is the version buster or stretch? Should I install the Ubuntu version??". To avoid such detours, I recommend using the above script.

By the way, if you have already installed k3s before installing Docker, you might run into some issues during the Docker installation. In that case, you should

/usr/local/bin/k3s-uninstall.sh

uninstall k3s, reboot the system, and then proceed with the Docker installation.

2. Installing k3s

curl -sfL https://get.k3s.io | sh -s - --docker

This command will install k3s. The --docker option specifies Docker as the container backend.

However, in my case, the service failed to start after installation.

[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
Job for k3s.service failed because the control process exited with error code.
See "systemctl status k3s.service" and "journalctl -xe" for details.
journalctl -xe

When I checked the logs, I saw the following message:

level=fatal msg="failed to find memory cgroup, you may need to add \"cgroup_memory=1 cgroup_enable=memory\" to your linux

So, as suggested, I added cgroup_memory=1 cgroup_enable=memory to /boot/cmdline.txt

console=serial0,115200 console=tty1 root=PARTUUID=97709164-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwai

console=serial0,115200 console=tty1 root=PARTUUID=97709164-02 rootfstype=ext4 elevator=deadline fsck.repair=yes cgroup_memory=1 cgroup_enable=memory rootwait


After doing this and rebooting the system, k3s started to work.

3. Retrieving kubeconfig

The config file is created at /etc/rancher/k3s/k3s.yaml, so

sudo cat /etc/rancher/k3s/k3s.yaml

to display it and copy it to your Mac with a name like .kube/config-raspi.

At that time, change the server: https://127.0.0.1:6443 part in the config to the hostname of your Raspberry Pi as seen from outside.

server: https://myraspi.local:6443

Then, on your Mac, run

KUBECONFIG=${HOME}/.kube/config-raspi kubectl get all

If you get a response, everything is set up correctly.

Currently unrated

Comments

Archive

2024
2023
2022
2021
2020
2019
2018
2017
2016
2015
2014
2013
2012
2011