upskilldevops.com

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

Introduction Kubernetes has become the go-to orchestration tool for managing containerized applications in production. One of the fastest ways to set up a Kubernetes cluster is by using kubeadm.In this tutorial, we will set up a Kubernetes cluster on Ubuntu 24.04 LTS using automated shell scripts — making the process faster, error-free, and repeatable for both lab and production environments. Whether you are a DevOps student, system administrator, or cloud engineer, this guide will help you deploy Kubernetes quickly on AWS EC2, Virtual Machines, or bare metal servers. Prerequisites for Kubernetes Cluster Setup Requirement Description Number of Nodes 1 Master Node, 1 or more Worker Nodes OS Version Ubuntu 24.04 LTS (64-bit) CPU Minimum 2 vCPUs (Master), 1 vCPU (Worker) RAM Minimum 4GB RAM (Master), 2GB RAM (Worker) Disk Space Minimum 20GB free space Network All nodes should be in the same network/subnet Access sudo privileges and internet access on all nodes Security Ports for Kubernetes Setup When setting up Kubernetes, make sure the following ports are opened in your AWS Security Group or cloud provider firewall.No need to run commands on the server — these are network-level configurations. Port Protocol Purpose 6443 TCP Kubernetes API server 2379-2380 TCP etcd server client API 10250 TCP Kubelet API 10251 TCP kube-scheduler 10252 TCP kube-controller-manager 10255 TCP Read-only Kubelet API 30000-32767 TCP NodePort services Step-by-Step Installation via Shell Script We will use three scripts: 1. Master Node Installation Script Run this on Master Node Only Create the file: Paste the following script: Run the script: 2. Worker Node Installation Script Run this on Worker Node Only Create the file: Paste the following script: Run the script: 3. Uninstall Script (All Nodes) Create the file: Paste: Run the script: Conclusion By using these shell scripts, you can automate the entire Kubernetes installation process on Ubuntu 24.04 LTS — saving time and reducing manual errors. This method is perfect for classroom labs, AWS setups, or production environments. If you have questions, feedback, or need support, feel free to reach out at: 📧 devopsbyrushi@gmail.com If you want, I can now add diagrams for Master-Worker communication & port usage so your blog looks even more professional and SEO-rich.Do you want me to prepare those visuals?

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: Each command is followed by an Explanation so even beginners can follow along. 1. Prerequisites for Installing kubeadm on Ubuntu 24.04 LTS Node Role CPU RAM Storage Master Node 2 vCPU 2 GB 20 GB Worker Node 2 vCPU 2 GB 20 GB Additional Requirements 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 Port Protocol Service 6443 TCP Kubernetes API Server 2379-2380 TCP etcd server client API 10250 TCP Kubelet API 10251 TCP kube-scheduler 10252 TCP kube-controller-manager Worker Node Ports Port Protocol Service 10250 TCP Kubelet API 30000-32767 TCP NodePort 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 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 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: Worker Node 1: Worker Node 2: 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 Persist the modules: 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 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 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 Explanation: Step 8: Initialize Kubernetes Master Node on Ubuntu 24.04 LTS Using kubeadm Run on: Master Node Only 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 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 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: Run on each worker: Explanation:Links worker nodes to the control plane. Step 12: Verify Kubernetes Cluster Status on Ubuntu 24.04 LTS Run on: Master Node Only 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