How to Install Kubernetes Cluster on Ubuntu 24.04 LTS (Step-by-Step Guide)
How to Install Kubernetes Cluster on Ubuntu 24.04 LTS (Step-by-Step Guide)
04 LTS (Step-by-Step
Guide)
Introduction
Kubernetes is a powerful container orchestration platform used for automating the deployment, scaling, and management of containerized applications. In this guide,
we will walk you through the step-by-step process of installing Kubernetes on Ubuntu 22.04. This cluster configuration includes a master node and worker nodes,
allowing you to harness the full power of Kubernetes.
Kubernetes Nodes
Master Nodes: These nodes play a crucial role in managing the control API calls for various components within the Kubernetes cluster. This includes overseeing
pods, replication controllers, services, nodes, and more.
Worker Nodes: Worker nodes are responsible for providing runtime environments for containers. It’s worth noting that a group of container pods can extend across
multiple worker nodes, ensuring optimal resource allocation and management.
Prerequisites
Before diving into the installation, ensure that your environment meets the following prerequisites:
Begin by ensuring that your system is up to date. Open a terminal and execute the following commands:
To enhance Kubernetes performance, disable swap and set essential kernel parameters. Run the following commands on all nodes to disable all swaps:
sudo swapoff -a
sudo sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
Configure the critical kernel parameters for Kubernetes using the following:
We are using the containerd runtime. Install containerd and its dependencies with the following commands:
After adding the repositories, install essential Kubernetes components, including kubectl, kubelet, and kubeadm, on all nodes with the following commands:
To start using your cluster, you need to run the following as a regular user:
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
export KUBECONFIG=/etc/kubernetes/admin.conf
Then you can join any number of worker nodes by running the following on each as root:
After the initialization is complete make a note of the kubeadm join command for future reference.
Next, use kubectl commands to check the cluster and node status:
kubectl get nodes
✍︎
✍︎
To enable communication between pods in the cluster, you need a network plugin. Install the Calico network plugin with the following command from the master
node:
kubectl apply -f https://raw.githubusercontent.com/projectcalico/calico/v3.25.0/manifests/calico.yaml
✍︎
✍︎