Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
July 10, 2022 10:12 pm GMT

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:-

  1. Ubuntu 22.04 WSL distrowhat 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. K3SK3s 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. AutoK3sAutoK3s 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 UsersDocumentation=man:sysusers.d(5) man:systemd-sysusers.service(8)DefaultDependencies=noConflicts=shutdown.targetAfter=systemd-remount-fs.serviceBefore=sysinit.target shutdown.target systemd-update-done.serviceConditionNeedsUpdate=/etc[Service]Type=oneshotRemainAfterExit=yesExecStart=systemd-sysusersTimeoutSec=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.listsudo 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 AutoK3sDownload 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-explorerchmod 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


Original Link: https://dev.to/msh2050/quickly-create-k3s-cluster-and-add-k3s-nodes-with-gui-tool-using-autok3s-installation-guide-in-wsl-3e5d

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To