How to Install Kubernetes (K8s) on Ubuntu 24.04: A Step-by-Step Guide

Kubernetes (K8s) has become the go-to container orchestration platform for modern cloud-native applications. Whether you’re a DevOps engineer, software developer, or IT operations specialist, learning how to install Kubernetes is essential. In this guide, we’ll walk you through the process of installing Kubernetes on Ubuntu 24.04 LTS, using kubeadm, the recommended tool by the Kubernetes community.
✅ Estimated Reading Time: 10 minutes
📦 Environment: Ubuntu 24.04 (Fresh Install), Root or sudo privileges, at least 2 CPUs and 2GB RAM per node
📋 Prerequisites
Before jumping into the installation, make sure you have:
- Two or more machines running Ubuntu 24.04 (one for the control plane/master and others as worker nodes)
- SSH access and root/sudo privileges
- A stable internet connection
- Swap memory disabled (Kubernetes does not support swap)
🔧 Step 1: Prepare the System
1.1 Update System Packages
$ sudo apt update && sudo apt upgrade -y
1.2 Disable Swap
$ sudo swapoff -a
$ sudo sed -i '/ swap / s/^/#/' /etc/fstab
1.3 Load Kernel Modules and Configure sysctl
$ cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf
overlay
br_netfilter
EOF
$ sudo modprobe overlay
$ sudo modprobe br_netfilter
Then configure the networking parameters:
$ cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
EOF
sudo sysctl --system
🐳 Step 2: Install Container Runtime (containerd)
Kubernetes supports multiple container runtimes. We’ll use containerd.
$ sudo apt install -y containerd
Configure containerd:
$ sudo mkdir -p /etc/containerd
$ containerd config default | sudo tee /etc/containerd/config.toml
Restart containerd:
sudo systemctl restart containerd
sudo systemctl enable containerd
🚀 Step 3: Install kubeadm, kubelet, and kubectl
3.1 Add Kubernetes Repository
$ sudo apt install -y apt-transport-https ca-certificates curl gpg
$ curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.30/deb/Release.key | sudo gpg --dearmor -o /usr/share/keyrings/kubernetes-archive-keyring.gpg
$ echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.30/deb/ /" | sudo tee /etc/apt/sources.list.d/kubernetes.list
$ sudo apt update
3.2 Install Kubernetes Components
$ sudo apt install -y kubelet kubeadm kubectl
$ sudo apt-mark hold kubelet kubeadm kubectl
🧠 Step 4: Initialize the Kubernetes Control Plane
Only run this on the master node:
$ sudo kubeadm init --pod-network-cidr=10.244.0.0/16
Once completed, follow the on-screen instructions. It will include:
$ mkdir -p $HOME/.kube
$ sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
$ sudo chown $(id -u):$(id -g) $HOME/.kube/config
🌐 Step 5: Install a Pod Network Add-On
Let’s install Flannel, a simple and lightweight CNI plugin.
$ kubectl apply -f https://raw.githubusercontent.com/flannel-io/flannel/master/Documentation/kube-flannel.yml
Wait for the network pods to reach Running
state:
$ kubectl get pods -n kube-system
🧩 Step 6: Join Worker Nodes
On the worker nodes, run the kubeadm join
command generated during the master init. It will look something like this:
$ sudo kubeadm join :6443 –token –discovery-token-ca-cert-hash sha256:
If you lost the token, you can create a new one:
$ sudo kubeadm token create --print-join-command
🔍 Step 7: Verify the Cluster
Run on the control plane:
$ kubectl get nodes
You should see the master and worker nodes in Ready state.
🛠 Optional: Enable kubectl Autocompletion
$ sudo apt install bash-completion
$ echo 'source <(kubectl completion bash)' >> ~/.bashrc
✅ Final Thoughts
Congratulations! You’ve successfully installed a Kubernetes cluster on Ubuntu 24.04. This setup is ideal for learning, development, and even lightweight production workloads. From here, you can begin deploying your first applications using kubectl
, setting up Helm, or exploring observability with Prometheus and Grafana.
📌 Quick Recap
Step | Description |
---|---|
1 | Update system & disable swap |
2 | Install and configure containerd |
3 | Add Kubernetes repo and install components |
4 | Initialize Kubernetes master node |
5 | Install Pod network add-on |
6 | Join worker nodes |
7 | Verify the cluster |