upskilldevops.com

How to Install kubeadm on Ubuntu 24.04 LTS – Secure & Step-by-Step Kubernetes Cluster Setup

Introduction

Setting up Kubernetes on Ubuntu 24.04 LTS with kubeadm is one of the most reliable ways to deploy a cluster for labs, testing, or production.
In this guide, you’ll learn how to:

  • Prepare your Ubuntu nodes
  • Install and configure Kubernetes
  • Secure your setup with the right firewall rules
  • Connect Master and Worker nodes
  • Verify your cluster

Each command is followed by an Explanation so even beginners can follow along.


1. Prerequisites for Installing kubeadm on Ubuntu 24.04 LTS

Node RoleCPURAMStorage
Master Node2 vCPU2 GB20 GB
Worker Node2 vCPU2 GB20 GB

Additional Requirements

  • Ubuntu 24.04 LTS installed on all servers
  • sudo or root access
  • Internet connectivity
  • Swap disabled
  • Hostnames configured (one unique name per node)

2. Security – Required Kubernetes Ports on Ubuntu 24.04 LTS

When setting up Kubernetes on cloud providers like AWS, Azure, or GCP, it’s best to open required ports in the Security Group or equivalent firewall settings instead of directly on the OS.

Master Node Ports

PortProtocolService
6443TCPKubernetes API Server
2379-2380TCPetcd server client API
10250TCPKubelet API
10251TCPkube-scheduler
10252TCPkube-controller-manager

Worker Node Ports

PortProtocolService
10250TCPKubelet API
30000-32767TCPNodePort Services

Explanation:
These ports enable communication between Kubernetes components and services. Make sure they are open in your cloud provider’s Security Group for smooth operation.


3. Kubernetes Installation Steps on Ubuntu 24.04 LTS

We will use clear numbering with node-specific instructions under each heading.


Step 1: Update and Upgrade Ubuntu 24.04 LTS for Kubernetes Installation

Run on: All Nodes

sudo apt update && sudo apt upgrade -y

Explanation:
Keeps your system secure and ensures compatibility with Kubernetes dependencies.


Step 2: Disable Swap on Ubuntu 24.04 LTS for Kubernetes

Run on: All Nodes

sudo swapoff -a
sudo sed -i '/ swap / s/^\(.*\)$/#\1/' /etc/fstab

Explanation:
Kubernetes requires swap to be disabled for stable memory allocation.


Step 3: Set Hostname for Kubernetes Nodes on Ubuntu 24.04 LTS

Run on: Each Node Separately

Master Node:

sudo hostnamectl set-hostname master-node
sudo reboot

Worker Node 1:

sudo hostnamectl set-hostname worker-node1
sudo reboot

Worker Node 2:

sudo hostnamectl set-hostname worker-node2
sudo reboot

Explanation:
Hostnames uniquely identify nodes in the cluster and simplify management.


Step 4: Load Kernel Modules for Kubernetes on Ubuntu 24.04 LTS

Run on: All Nodes

sudo modprobe overlay
sudo modprobe br_netfilter

Persist the modules:

sudo tee /etc/modules-load.d/k8s.conf <<EOF
overlay
br_netfilter
EOF

Explanation:
Required for Kubernetes networking and container isolation.


Step 5: Configure sysctl Network Settings for Kubernetes on Ubuntu 24.04 LTS

Run on: All Nodes

sudo tee /etc/sysctl.d/k8s.conf <<EOF
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
EOF
sudo sysctl --system

Explanation:
Enables packet forwarding and proper handling of bridged network traffic.


Step 6: Install containerd Runtime on Ubuntu 24.04 LTS for Kubernetes

Run on: All Nodes

sudo apt install -y containerd
sudo mkdir -p /etc/containerd
containerd config default | sudo tee /etc/containerd/config.toml
sudo systemctl restart containerd
sudo systemctl enable containerd

Explanation:
containerd is the container runtime that manages containers for Kubernetes pods.


Step 7: Install kubeadm, kubelet, and kubectl on Ubuntu 24.04 LTS

Run on: All Nodes

sudo apt install -y apt-transport-https ca-certificates curl gpg
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.30/deb/Release.key | \
sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
echo "deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] \
https://pkgs.k8s.io/core:/stable:/v1.30/deb/ /" | \
sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt update
sudo apt install -y kubelet kubeadm kubectl
sudo apt-mark hold kubelet kubeadm kubectl

Explanation:

  • kubeadm → Bootstraps Kubernetes cluster.
  • kubelet → Runs containers on each node.
  • kubectl → CLI tool to manage Kubernetes.

Step 8: Initialize Kubernetes Master Node on Ubuntu 24.04 LTS Using kubeadm

Run on: Master Node Only

sudo kubeadm init --pod-network-cidr=192.168.0.0/16

Explanation:
Sets up the Kubernetes control plane and configures pod networking.


Step 9: Configure kubectl Access for Kubernetes Master Node on Ubuntu 24.04 LTS

Run on: Master Node Only

mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

Explanation:
Allows the kubectl CLI to be used without root privileges.


Step 10: Install Calico CNI Plugin on Ubuntu 24.04 LTS for Kubernetes Networking

Run on: Master Node Only

kubectl apply -f https://raw.githubusercontent.com/projectcalico/calico/v3.25.0/manifests/calico.yaml

Explanation:
Provides networking for pod-to-pod communication.


Step 11: Join Kubernetes Worker Nodes to the Cluster on Ubuntu 24.04 LTS

Run on: Worker Nodes Only

Get join command from Master:

kubeadm token create --print-join-command

Run on each worker:

sudo kubeadm join <MASTER-IP>:6443 --token <TOKEN> \
--discovery-token-ca-cert-hash sha256:<HASH>

Explanation:
Links worker nodes to the control plane.


Step 12: Verify Kubernetes Cluster Status on Ubuntu 24.04 LTS

Run on: Master Node Only

kubectl get nodes
kubectl get pods -n kube-system

Explanation:
Checks if all nodes are connected and all core pods are running.


Conclusion

You’ve now set up a working Kubernetes cluster on Ubuntu 24.04 LTS using kubeadm.
This method works perfectly for both lab environments and production setups with proper configuration.

If you have questions, feedback, or need support, feel free to reach out at:
📧 devopsbyrushi@gmail.com


Leave a Comment