Quickly create K3s cluster and add K3s nodes with GUI Tool using AutoK3s (Installation guide in WSL)

AutoK3s is a new tool that will make it easy to install and manage Kubernetes clusters in many platforms.
In this tutorial, we will install Kubernetes in windows WSL with the use of:-

Ubuntu 22.04 WSL distro
what is amazing in this distro is that the…


This content originally appeared on DEV Community and was authored by msh2050

AutoK3s is a new tool that will make it easy to install and manage Kubernetes clusters in many platforms.
In this tutorial, we will install Kubernetes in windows WSL with the use of:-

  1. Ubuntu 22.04 WSL distro what is amazing in this distro is that they have built in systemctl. If you chose another distro, you should use other methods to make docker and other services start.
  2. Docker for Linux (without docker desktop) as you may know, docker desktop is not free anymore, and I found it use more resources from the pc.
  3. K3S K3s is a highly available, certified Kubernetes distribution designed for production workloads. The most important it is "Lightweight Kubernetes"
  4. K3D k3d is a lightweight wrapper to run k3s in docker.
  5. AutoK3s AutoK3s is a lightweight tool for simplifying K3s cluster management.

Install a Linux distro

it is recommended to use Ubuntu 22.04 in this tutorial. You can download it from Microsoft store.

It is advisable to upgrade.

sudo apt update && sudo apt upgrade

Enable systemctl

in your WSL edit /etc/wsl.conf

sudo nano /etc/wsl.conf

add the following line:

[boot]
command="/usr/libexec/wsl-systemd"

then close the terminal and restart WSL with the following command in your PowerShell

 wsl --shutdown

then you can start new WSL shell and check that systemctl is working

 ps aux

systemctl
not that first line(PID 1) is systemctl

then check systemctl status:

systemctl status

for me, I got 3 failed services:

  • ssh.service
  • systemd-remount-fs.service
  • systemd-sysusers.service

to solve ssh service :

 apt-get install openssh-server openssh-client
 dpkg-reconfigure openssh-server

for the rest:

  • comment out the line in the /etc/fstab:
#LABEL=cloudimg-rootfs   /        ext4   discard,errors=remount-ro       0 1
  • open /usr/lib/systemd/system/systemd-sysusers.service and delete all lines, then add:
[Unit]
Description=Create System Users
Documentation=man:sysusers.d(5) man:systemd-sysusers.service(8)
DefaultDependencies=no
Conflicts=shutdown.target
After=systemd-remount-fs.service
Before=sysinit.target shutdown.target systemd-update-done.service
ConditionNeedsUpdate=/etc

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=systemd-sysusers
TimeoutSec=90

[Service]
LoadCredential=

Finally, restart and check the services again.

Install Docker

the instructions for installing Docker in details from this tutorial, we can skip Sharing dockerd and adding script (because we use systemctl) in short this can be done with the following:

  • Install dependencies
sudo apt install --no-install-recommends apt-transport-https ca-certificates curl gnupg2
  • Switch to legacy iptables
update-alternatives --config iptables

select iptables-legacy

  • package repository configuration

First, temporarily set some OS-specific variables:

. /etc/os-release

Then, make sure that apt will trust the repo:

curl -fsSL https://download.docker.com/linux/${ID}/gpg | sudo tee /etc/apt/trusted.gpg.d/docker.asc

Then add and update the repo information so that apt will use it in the future:

echo "deb [arch=amd64] https://download.docker.com/linux/${ID} ${VERSION_CODENAME} stable" | sudo tee /etc/apt/sources.list.d/docker.list
sudo apt update
  • Install Docker
sudo apt install docker-ce docker-ce-cli containerd.io
  • Add user to Docker group
sudo usermod -aG docker $USER

Finally, close that WSL window, and launch WSL again. And check if docker is working:

 docker run --rm hello-world

Install K3D and AutoK3s

  • Install K3D
curl -s https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash
  • Install AutoK3s Download the binary from the release page.
curl https://github.com/cnrancher/autok3s/releases/download/v0.5.1/autok3s_linux_amd64 --create-dirs -o ~/bin/autok3s

Make it executable

chmod 755 ~/bin/autok3s

then add to path

echo 'export PATH="$HOME/bin:$PATH"' >> ~/.bashrc
  • install kube-explorer (optional)
curl https://github.com/cnrancher/kube-explorer/releases/download/v0.2.9/kube-explorer-linux-amd64 --create-dirs -o ~/bin/kube-explorer

chmod 755 $HOME/bin/kube-explorer

start autok3s to deploy Kubernetes cluster

autok3s serve

Open 127.0.0.1:8080 on your browser to start create, delete modify Kubernetes clusters.

autok3s

Select k3d as provide and give name to the cluster and specify how many mater/worker nodes you want.

This is a sample option I used to build a cluster with one master node and one worker node and limit their ram usage to 1 GB
options

You can add the explorer to the cluster

explorer


This content originally appeared on DEV Community and was authored by msh2050


Print Share Comment Cite Upload Translate Updates
APA

msh2050 | Sciencx (2022-07-10T22:12:30+00:00) Quickly create K3s cluster and add K3s nodes with GUI Tool using AutoK3s (Installation guide in WSL). Retrieved from https://www.scien.cx/2022/07/10/quickly-create-k3s-cluster-and-add-k3s-nodes-with-gui-tool-using-autok3s-installation-guide-in-wsl/

MLA
" » Quickly create K3s cluster and add K3s nodes with GUI Tool using AutoK3s (Installation guide in WSL)." msh2050 | Sciencx - Sunday July 10, 2022, https://www.scien.cx/2022/07/10/quickly-create-k3s-cluster-and-add-k3s-nodes-with-gui-tool-using-autok3s-installation-guide-in-wsl/
HARVARD
msh2050 | Sciencx Sunday July 10, 2022 » Quickly create K3s cluster and add K3s nodes with GUI Tool using AutoK3s (Installation guide in WSL)., viewed ,<https://www.scien.cx/2022/07/10/quickly-create-k3s-cluster-and-add-k3s-nodes-with-gui-tool-using-autok3s-installation-guide-in-wsl/>
VANCOUVER
msh2050 | Sciencx - » Quickly create K3s cluster and add K3s nodes with GUI Tool using AutoK3s (Installation guide in WSL). [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/07/10/quickly-create-k3s-cluster-and-add-k3s-nodes-with-gui-tool-using-autok3s-installation-guide-in-wsl/
CHICAGO
" » Quickly create K3s cluster and add K3s nodes with GUI Tool using AutoK3s (Installation guide in WSL)." msh2050 | Sciencx - Accessed . https://www.scien.cx/2022/07/10/quickly-create-k3s-cluster-and-add-k3s-nodes-with-gui-tool-using-autok3s-installation-guide-in-wsl/
IEEE
" » Quickly create K3s cluster and add K3s nodes with GUI Tool using AutoK3s (Installation guide in WSL)." msh2050 | Sciencx [Online]. Available: https://www.scien.cx/2022/07/10/quickly-create-k3s-cluster-and-add-k3s-nodes-with-gui-tool-using-autok3s-installation-guide-in-wsl/. [Accessed: ]
rf:citation
» Quickly create K3s cluster and add K3s nodes with GUI Tool using AutoK3s (Installation guide in WSL) | msh2050 | Sciencx | https://www.scien.cx/2022/07/10/quickly-create-k3s-cluster-and-add-k3s-nodes-with-gui-tool-using-autok3s-installation-guide-in-wsl/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.