K3s is a lightweight, easy-to-install distribution of Kubernetes designed for resource-constrained environments, such as edge computing, IoT devices, and development/testing environments. It is developed by Rancher Labs, an organization known for its Kubernetes management platform.

In this tutorial, we will show you how to install Kubernetes using K3s on Ubuntu 24.04.

Step 1 – Install K3s

First, install the curl package for a smooth K3s installation.

apt install curl -y

Next, use the curl command to download and run the K3s installation script.

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

Once K3s has been installed, you can verify the K3s service using the following command.

systemctl status k3s

Output:

● k3s.service - Lightweight Kubernetes
     Loaded: loaded (/etc/systemd/system/k3s.service; enabled; preset: enabled)
     Active: active (running) since Tue 2025-05-27 07:04:59 UTC; 2s ago
       Docs: https://k3s.io
    Process: 23962 ExecStartPre=/bin/sh -xc ! /usr/bin/systemctl is-enabled --quiet nm-cloud-setup.service 2>/dev/null (code=exited, status=0/SUCCESS)
    Process: 23964 ExecStartPre=/sbin/modprobe br_netfilter (code=exited, status=0/SUCCESS)
    Process: 23968 ExecStartPre=/sbin/modprobe overlay (code=exited, status=0/SUCCESS)
   Main PID: 23975 (k3s-server)
      Tasks: 20
     Memory: 464.0M (peak: 465.0M)
        CPU: 11.019s
     CGroup: /system.slice/k3s.service
             ├─23975 "/usr/local/bin/k3s server"
             └─23996 "containerd "

Step 2 – Access Kubernetes Cluster

You will need to configure kubectl to access and interact with the Kubernetes cluster via the command line.

First, create a directory to store kubectl configuration.

mkdir ~/.kube

Next, copy the Kubernetes configuration file inside the .kube directory.

cp /etc/rancher/k3s/k3s.yaml ~/.kube/config 
chmod 600 ~/.kube/config 

Next, expose the path of the kubectl configuration file.

export KUBECONFIG=~/.kube/config

Next, verify the Kubernetes cluster nodes using the kubectl command.

kubectl get nodes

Output.

NAME       STATUS   ROLES                  AGE   VERSION
ubuntu24   Ready    control-plane,master   51s   v1.32.5+k3s1

You can also see the Kubernetes cluster information using the following command.

kubectl cluster-info

Output:

Kubernetes control plane is running at https://127.0.0.1:6443
CoreDNS is running at https://127.0.0.1:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
Metrics-server is running at https://127.0.0.1:6443/api/v1/namespaces/kube-system/services/https:metrics-server:https/proxy

Step 3 – Create an Nginx Deployment

To validate the Kubernetes installation, we will deploy a Nginx-based application and expose it via NodePort.

First, create an Nginx deployment using the following command.

kubectl create deployment  nginx-app --image nginx --replicas 2

Next, verify the Nginx deployment using the following command.

kubectl get deployment nginx-app

Output.

NAME        READY   UP-TO-DATE   AVAILABLE   AGE
nginx-app   2/2     2            2           10s

Next, verify the Nginx pods using the following command.

kubectl get pods

Output:

NAME                        READY   STATUS    RESTARTS   AGE
nginx-app-5777b5f95-lhcpp   1/1     Running   0          22s
nginx-app-5777b5f95-2j6ld   1/1     Running   0          22s

Next, expose the nginx-app deployment using NodePort.

kubectl expose deployment nginx-app --type NodePort --port 80

Next, get the IP address of nginx-app using the following command:

kubectl get svc nginx-app

Output:

NAME        TYPE       CLUSTER-IP     EXTERNAL-IP   PORT(S)        AGE
nginx-app   NodePort   10.43.162.54           80:31588/TCP   5s

Now, use the IP address from the above output and run the curl command to access the nginx-app.

curl http://10.43.162.54

If everything is fine, you will see the following output:

<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>

Conclusion

Overall, K3s offers a compelling solution for scenarios where a full-fledged Kubernetes deployment may be impractical or overly resource-intensive. Its lightweight design, ease of installation, and focus on security make it an attractive choice for edge computing, IoT deployments, and development/testing environments. You can now easily deploy Kubernetes cluster using K3s on dedicated server hosting from Atlantic.Net!