K3s Kubernetes Cluster Setup on Ubuntu 22.04: A Beginner's Guide
Post Category: Blog > Products > Applications Cloud

How to set up a K3s Kubernetes Cluster on Ubuntu 22.04

In this article, you will find a detailed walkthrough on installing and configuring K3s on Ubuntu.  With K3s, it is possible to effortlessly deploy a Kubernetes cluster by utilizing a small binary in minutes.

What is Kubernetes (K8s)?

Kubernetes is a container orchestration that can build, scale, manage, and deploy containerized applications anywhere. K8s is just a General-purpose container distribution, It provides a flexible and scalable platform for building, deploying, and managing applications in a wide variety of environments. Whether you’re running a small application on a single server, or managing a large-scale deployment across multiple clusters, Kubernetes can help you streamline your workflow and improve your application’s performance.

What is K3s?

K3s is a lightweight Kubernetes distribution that comes in a single-binary package. It is designed to be resource-friendly, making it perfect for edge computing, IoT deployments, CI/CD pipelines, and local development. With easy setup, efficient use of resources, baked-in security, and cross-platform compatibility, K3s offers all the power of Kubernetes in a more lightweight package. Whether you’re a beginner or a seasoned pro, K3s is the perfect choice to bring Kubernetes to your resource-constrained scenarios.

Before installing/deploying K3s it is important to have a clear understanding of the difference between K3s and K8s, we recommend reading our blog post titled “K8s VS k3s – what is the difference?” This will provide you with valuable insights that you can consider before installing any Kubernetes distribution.

To start, the initial setup for the Ubuntu server needs to be executed. Taking a few additional steps will enhance the server’s security and usability, providing a strong base for future actions.

Manual Installation of  K3s:

Step 1: Root Access

To log in to your server, you must have access to the server’s public IP address. Furthermore, if you have opted for SSH key authentication, you will need to have either the password or private key linked to the root user account.

If you are not connected to your server currently, log in as the root user using the following command. Substitute the highlighted your_server_ip portion of the command with your server’s public IP address:

$ ssh root@your_server_ip

If you encounter a warning concerning host authenticity, accept it. When your server uses password authentication, enter your root password for logging in. If you utilize an SSH key that has a passphrase, you may need to input the passphrase during the first usage of the key in each session. In the instance that this is your first time accessing the server with a password, you may need to change the root password. Observe the provided instructions to modify the password if prompted.

Step 2: Create a New User

Once you log in as root, you’ll be able to add the new user account. In the future, we’ll log in with this new account instead of root.

This example creates a new user called io_lucas, but you should replace that with a username that you like:

# sudo adduser  io_lucas

Check out our Kubernetes Hosting Plans

Step: 3 Setting up the firewall security

By leveraging the UFW firewall, Ubuntu servers can enforce restrictions on connections exclusively to designated services. You can establish a rudimentary firewall setup by utilizing this application. Upon installation, applications can register their profiles with UFW, enabling streamlined management by name. UFW already has a registered profile for OpenSSH, the service used to connect to the server.

By entering the command, you can access the list of installed UFW profiles:

# ufw app list

To guarantee future server access, the firewall must be configured to authorize SSH connections. Simply input the provided command to allow these connections:

# ufw allow OpenSSH

Enable the firewall by executing this command:

# ufw enable

After executing this command you will receive this kind of output, Thus type “y” to enable the Firewall and “Enter”

The command may disrupt existing SSH connections. 
Proceed with the operation (y|n)?

Now, the Firewall is running active and you can see the status of “ufw” by executing this command:

# ufw status

The Firewall is operational and has blocked any form of communication except for SSH. By following these steps, you will be able to witness these outcomes…From here you have a proper foundation of the server (Ubuntu 22.04) and now you can install K3s Kubernetes cluster on this server.

Step 4: Install K3s

To install k3s use this command:

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

By utilizing the “curl” command, the script located at https://get.k3s.io is fetched and subsequently run through piping it to “sh -“. Once the script is executed, the installation process of a K3s cluster commences using the default configuration options, thereby establishing a Kubernetes cluster with only one node.

This script output shows the installation process and now if you want to check the process status for installation. To check this status execute the system command:

# systemctl status k3s 

You can see the output like this:

# systemctl status k3s 

Check out our Kubernetes Hosting Plans

Step 5: Default Kubernetes Object:

Next, Kubernetes got default objects while installing K3s so you don’t need to install them individually because of automated installed objects. To know all the objects of Kubernetes by adding “kubesystem”. “Kubectl” (Kubernetes specific Command line tool) is installed already while k3s installation, So you have to check what kind of default objects are installed by running this command:

# sudo kubectl get all -n kube-system

In this output, you can see the other deployments also done while K3s installation like corns, local-path-provisioner, traefik, and metrics-server.

Step 6: Adjust the Configuration setting in K3s

By using the default setup, you installed K3s, but it is also possible to customize the configuration for specific cluster behavior. In this step, you will discover how to utilize environment variables in K3s to modify the configuration in the install script.

When installing k3s, it is worth noting that the default setup includes a traefik ingress controller which can be disabled if necessary.

If you want to disable Traefik while installing K3s, you have the option to use the environment variable INSTALL_K3S_EXEC to pass the flags to the K3s service.

# curl -sfL https://get.k3s.io  | INSTALL_K3S_EXEC="--disable=traefik" sh -

After this, you will get output like this:

Now execute again this command to that traefik ingress controller is disabled or not.

So within the K3s installation, you can custom modify the objects and also disable the options as per your requirements.

Check out our Kubernetes Hosting Plans

Step 7: Uninstall K3s:

To uninstall the K3s cluster you need to run the command that cleans up the full software that shell commands are already created while installing K3s and also clean up other objects installed during cluster installation.

Run this command for uninstallation of K3s:

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

You will see these outputs.

Now you can see the status of the uninstalled cluster by running this command:]

# systemctl status k3s

By referring to the above output, one can easily follow the step-by-step process of manually installing and uninstalling the K3s cluster on Ubuntu 22.04.

You can install the K3s lightweight version and full-fat Kubernetes cluster (K8s) that is directly ready to deploy to your system and drive features like automated scaling, On-demand backup availability, inbuilt security features, round-the-clock ticket and live chat support, and most importantly AccuWeb.Cloud provides the first 90 days of free managed hosting so that you can scale your application/software effectively.

To deploy a managed Kubernetes cluster, refer to this link and get to know more about AccuWeb.Cloud’s all products.


In this article, you installed the K3s cluster in Ubuntu 22.04 from scratch, understand of inbuilt installed objects in the cluster, and how to configure and change as per your requirements with practical examples. Now, you can set up and deploy the cluster by yourself. If you have any questions and need support for installing K3s in your server, then feel free to contact our support team.