Menu

Virtual Geek

Tales from real IT system administrators world and non-production environment

Install and Setup your own Kubernetes Cluster with K3s

K3s is a trivial, lightweight, easy to install, implement, and operate version of standard Kubernetes (K8s). The main part is it is not a fork of Kubernetes. K3s is a certified Kubernetes lightweight distribution. It can be used to run production workload as well. I found it is easier to install K3S than Minikube How to Install Minikube on Ubuntu - Step by Step

I am installing K3s on the Ubuntu system, for this first I am updating and upgrading the Ubuntu OS system before proceeding. Later install curl tool.

root@AnsibleAWX:~#
root@AnsibleAWX:~# apt-get update
Hit:1 http://us.archive.ubuntu.com/ubuntu focal InRelease
Hit:2 http://us.archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:3 http://us.archive.ubuntu.com/ubuntu focal-backports InRelease
Hit:4 http://security.ubuntu.com/ubuntu focal-security InRelease
Reading package lists... Done
root@AnsibleAWX:~#
root@AnsibleAWX:~# apt-get upgrade -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages have been kept back:
  fwupd gir1.2-javascriptcoregtk-4.0 gir1.2-webkit2-4.0 gnome-shell-extension-desktop-icons gvfs gvfs-backends gvfs-bin gvfs-common gvfs-daemons gvfs-fuse gvfs-libs
  libegl-mesa0 libfwupd2 libfwupdplugin1 libgbm1 libgl1-mesa-dri libglapi-mesa libglx-mesa0 libjavascriptcoregtk-4.0-18 libsmbclient libwbclient0 libwebkit2gtk-4.0-37
  libxatracker2 linux-generic-hwe-20.04 linux-headers-generic-hwe-20.04 linux-image-generic-hwe-20.04 mesa-vulkan-drivers samba-libs ubuntu-advantage-tools
0 upgraded, 0 newly installed, 0 to remove and 29 not upgraded.
root@AnsibleAWX:~#
root@AnsibleAWX:~# apt-get install curl vim
Reading package lists... Done
Building dependency tree
Reading state information... Done
curl is already the newest version (7.68.0-1ubuntu2.14).
vim is already the newest version (2:8.1.2269-1ubuntu5.9).
0 upgraded, 0 newly installed, 0 to remove and 29 not upgraded.
root@AnsibleAWX:~#

Next to install k3s, bash sh script exists online on k3s.io website, which needs to be downloaded with curl and it will install it at the same time. It will create a Kubernetes environment for you, so no other tools are required to install.

root@AnsibleAWX:~#
root@AnsibleAWX:~# curl -sfL https://get.k3s.io | sh -
[INFO]  Finding release for channel stable
[INFO]  Using v1.25.4+k3s1 as release
[INFO]  Downloading hash https://github.com/k3s-io/k3s/releases/download/v1.25.4+k3s1/sha256sum-amd64.txt
[INFO]  Downloading binary https://github.com/k3s-io/k3s/releases/download/v1.25.4+k3s1/k3s
[INFO]  Verifying binary download
[INFO]  Installing k3s to /usr/local/bin/k3s
[INFO]  Skipping installation of SELinux RPM
[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
root@AnsibleAWX:~#

Microsoft Windows ubuntu curl -sfL get.k3s.io sh bash kubernetes binary k3s k8s symlink sh systemd configuration lightweight kubernetes distribution selinux rpm.jpg

Once the Kubernetes cluster is set up, check the status of K3s by running the below command it's all good and ready to deploy pods.

root@AnsibleAWX:~#
root@AnsibleAWX:~# kubectl get nodes
NAME         STATUS   ROLES                  AGE     VERSION
ansibleawx   Ready    control-plane,master   2m56s   v1.25.4+k3s1
root@AnsibleAWX:~#
root@AnsibleAWX:~# kubectl get pods -A
NAMESPACE     NAME                                      READY   STATUS      RESTARTS   AGE
kube-system   coredns-597584b69b-mq62g                  1/1     Running     0          3m11s
kube-system   local-path-provisioner-79f67d76f8-8rj7d   1/1     Running     0          3m11s
kube-system   helm-install-traefik-crd-d2g28            0/1     Completed   0          3m12s
kube-system   helm-install-traefik-29p82                0/1     Completed   1          3m12s
kube-system   svclb-traefik-f936d094-mrh6p              2/2     Running     0          2m54s
kube-system   metrics-server-5c8978b444-xtkmx           1/1     Running     0          3m11s
kube-system   traefik-bb69b68cd-m9bb8                   1/1     Running     0          2m54s
root@AnsibleAWX:~#

Kubernetes k3s k8s kubectl get nodes kubectl get pod -A vmware vsphere vcenter esxi bash k3s io k3d google powershell pod container sidecar.jpg

Useful Articles
Configure Nginx Load Balancer for the Kubernetes API Server - Part 1
Install and configure Kubernetes cluster master nodes using kubeadm - Part 2
Install and configure Kubernetes cluster worker nodes using kubeadm - Part 3
Kubernetes kubeadm join couldn't validate the identity of the API server connection refused
Kubernetes kubeadm join could not find a jws signature in the cluster-info ConfigMap for token ID
Setup and deploy Ingress controller for Kubernetes on Bare Metal servers
Setup HAProxy for Ingress Controller Kubernetes Cluster

Go Back

Comment

Blog Search

Page Views

8960500

Follow me on Blogarama