How to Install Kubernetes Using K3s On Ubuntu 24.04

Are you looking for an easy guide for installing Kubernetes on Ubuntu 24.04?

A step-by-step guide on this page will explain how to install Kubernetes using k3s on Ubuntu 24.04.

What Is Kubernetes?

Kubernetes is a powerful, open-source container orchestration platform that automates the deployment, scaling, and management of containerized applications. It abstracts the underlying infrastructure, enabling developers and DevOps teams to deploy applications consistently across on-premises, cloud, and hybrid environments. Kubernetes simplifies complex container management, ensuring high availability, scalability, and reliability for modern microservices architectures.

What Is k3s? A Lightweight Kubernetes Alternative

k3s is a lightweight Kubernetes distribution specifically designed for resource-constrained environments. Developed by Rancher Labs, k3s is ideal for edge computing, IoT (Internet of Things) devices, CI/CD pipelines, and local development environments. Despite its small binary size and reduced resource requirements, k3s delivers full Kubernetes API compatibility, making it a powerful yet efficient solution for small-scale or remote deployments.

Prerequisites

  • Pre-Install Ubuntu 24.04 System
  • SSH access to your Ubuntu 24.04
  • Sudo user with admin access
  • Internet Connectivity

Without any further delay, lets deep dive into Kubernetes installation using k3s.

1. Update System Packages

First, let’s ensure that all system packages are up to date. Open a terminal and run the following apt commands:

$ sudo apt update
$ sudo apt upgrade -y

2. Install k3s dependencies

Run beneath command to install curl and wget command for smooth k3s installation.

$ sudo apt install curl wget -y

3. Install Kubernetes Using K3s on Ubuntu 24.04

Next, download and run k3s script which will setup the Kubernetes on your Ubuntu 24.04, run beneath curl command.

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

 

Install Kubernetes Using K3s on Ubuntu 24.04

Above command may take couple of minutes depending on your internet speed. Once the command is executed successfully, we will get the output something like above.

Verify the K3s service, if everything went smoothly, you should see output indicating that the k3s service is active and running.

$ sudo systemctl status k3s

Verify K3s Kubernetes Service Ubuntu 24.04

4. Access Kubernetes Cluster

To access and manage your k3s Kubernetes cluster, you need to configure the kubectl command to communicate with the k3s API server. Execute the following commands sequentially to complete the setup.

$ mkdir ~/.kube
$ sudo cp /etc/rancher/k3s/k3s.yaml ~/.kube/config && sudo chown $USER ~/.kube/config
$ sudo chmod 600 ~/.kube/config && export KUBECONFIG=~/.kube/config

KubeConfig file For k3s Kubernetes Ubuntu 24.04

No,  run following kubectl commands to start interacting with Kubernetes.

$ kubectl get nodes
$ kubectl cluster-info

 

k3s Kubernetes Cluster Information

Great, output above shows that out Kubernetes cluster is up and running.

5. Validate K3s Kubernetes Installation

To verify your k3s Kubernetes installation, deploy a sample NGINX based application and expose it using a NodePort service, as demonstrated below

$ kubectl create deployment nginx-app --image=nginx --replicas=2
$ kubectl get deployment nginx-app
$ kubectl get pods

Create Nginx Based Deployment On k3s Kubernetes Ubuntu 24.04

Next, expose the nginx-app deployment using NodePort, execute following command.

$ kubectl expose deployment nginx-app --type NodePort --port 80
$ kubectl get svc nginx-app

Expose Nginx Deployment NodePort K3s Kubernetes

Now access nginx-app using its nodeport, run

$ curl http://<Your-Ubuntu-24-04-IP-Address><NodePort>

Access Nginx Deployed on K3s Kubernetes Ubuntu 24.04

Output above confirms that we are able to access our nginx based application.

That’s all from this guide, I believe you have found it useful and informative. Feel free to post your queries and feedback in below comments section.

Also Read : How to Install Kubernetes Dashboard Using Helm

Leave a Comment

Your email address will not be published. Required fields are marked *