I will walk you through the k3s installation and configuration steps in this article.
- Here is a video tutorial; continue reading for a list of written instructions.
Exercises to complete:
- Install k3s
- Remove traefik
- Install k3s without traefik
Introduction
I decided to install k3s on a Raspberry Pi CM4 IO board with Compute Module 4 to show that it is possible to run a single-node cluster.
Install k3s
1
|
sudo curl -sfL https://get.k3s.io | sh
|
Check k3s status
1
|
sudo systemctl status k3s
|
Remove the k3s
Switch to root
1
2
3
4
|
sudo -i
cd /usr/local/bin
./k3s-killall.sh
./k3s-uninstall.sh
|
Install k3s securely
1
2
3
|
sudo curl -sfL https://get.k3s.io | sh -s - --write-kubeconfig-mode 644
or
sudo curl -sfL https://get.k3s.io | K3S_KUBECONFIG_MODE="644" sh -
|
Find kubeconfig files
1
|
sudo find / -iname "*.kubeconfig"
|
Check kubeconfig file permissions
1
2
|
sudo stat -c %a /var/lib/rancher/k3s/agent/kubelet.kubeconfig
600
|
Check k3s status
1
|
sudo systemctl status k3s
|
Add cgroup entries into the cmdline.txt
1
|
sudo vim /boot/cmdline.txt
|
- Add at the end of the line that starts with console= the below entries:
1
|
cgroup_memory=1 cgroup_enable=memory
|
Reboot the server
Check node status
Check pods
Get rid of the traefik
1
|
kubectl -n kube-system delete helmcharts.helm.cattle.io traefik
|
Stop k3s
1
|
sudo systemctl stop k3s
|
Edit k3s service file
1
|
sudo vim /etc/systemd/system/k3s.service
|
Modify ExectStart
–disable=traefik
So it should look like this:
1
2
3
4
5
6
|
ExecStart=/usr/local/bin/k3s \
server \
--disable=traefik \
'--write-kubeconfig-mode' \
'644' \
...
|
Reload daemon
1
|
sudo systemctl daemon-reload
|
Delete traefik.yaml
1
|
sudo rm /var/lib/rancher/k3s/server/manifests/traefik.yaml
|
Start k3s and check the status
1
2
|
sudo systemctl start k3s
sudo systemctl status k3s
|
Check pods
Install k3s securely without the traefik
1
2
3
|
sudo curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="--disable traefik" sh -s - --write-kubeconfig-mode 644
or
sudo curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="--disable traefik" K3S_KUBECONFIG_MODE="644" sh -
|
Check pods