How To Install Kubectl on Ubuntu 24.04 LTS
In this tutorial, we will show you how to install Kubectl on Ubuntu 24.04 LTS. Kubernetes has emerged as the de facto standard for container orchestration, enabling organizations to automate the deployment, scaling, and management of containerized applications. As the adoption of Kubernetes continues to grow, mastering kubectl has become a crucial skill for DevOps engineers, site reliability engineers (SREs), and developers alike.
Kubectl is a command-line interface (CLI) tool that allows you to interact with Kubernetes clusters, enabling you to perform various operations such as creating and managing resources, inspecting cluster components, and troubleshooting issues. Whether you’re running a local development environment or managing a production-grade Kubernetes cluster, kubectl is an indispensable tool in your DevOps arsenal.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo
‘ to the commands to get root privileges. I will show you the step-by-step installation of the Kubectl on Ubuntu 24.04 (Noble Numbat). You can follow the same instructions for Ubuntu 22.04 and any other Debian-based distribution like Linux Mint, Elementary OS, Pop!_OS, and more as well.
Prerequisites
- A server running one of the following operating systems: Ubuntu and any other Debian-based distribution like Linux Mint.
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- SSH access to the server (or just open Terminal if you’re on a desktop).
- An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies.
- An Ubuntu 24.04 system with root access or a user with sudo privileges.
Install Kubectl on Ubuntu 24.04 LTS Noble Numbat
Step 1. Updating the Package Repository.
Before installing any package, it’s a good practice to update the package lists to ensure you have access to the latest available versions. Open a terminal and run the following command:
sudo apt update
This command will fetch the latest package information from the Ubuntu repositories, allowing you to install the most recent version of Kubectl and its dependencies. Updating the package repository is crucial to maintaining the security and stability of your system.
Step 2. Installing Kubectl on Ubuntu 24.04.
- Method 1: Installing kubectl Using Snap Package Management
Snap is a modern package management system that provides an alternative to traditional package managers like apt. It offers several advantages, such as automatic updates, confinement for improved security, and the ability to install packages from different distributions on the same system.
Before installing kubectl via snap, ensure that the snap daemon is installed on your Ubuntu 24.04 LTS system. Run the following command to install the snap daemon:
sudo apt install snapd
With the snap daemon installed, you can now install kubectl using the following command:
sudo snap install kubectl --classic
The --classic
flag is required to ensure that kubectl has the necessary permissions to interact with the Kubernetes cluster.
After the installation is complete, verify that kubectl is installed correctly by checking its version:
kubectl version --client
- Method 2: Installing kubectl by Downloading the Binary Directly
If you prefer a more manual approach or have specific version requirements, you can download the kubectl binary directly from the official Kubernetes release repository.
Visit the official Kubernetes release page and locate the desired version of kubectl. Copy the link to the binary for your system architecture (e.g., amd64 for 64-bit systems).
# Using curl curl -LO https://dl.k8s.io/release/v1.30.0/bin/linux/amd64/kubectl # Using wget wget https://dl.k8s.io/release/v1.30.0/bin/linux/amd64/kubectl
After downloading the binary, you need to make it executable:
chmod +x kubectl
To make kubectl accessible from any directory, move the binary to a directory included in your system’s PATH
environment variable, such as /usr/local/bin
:
sudo mv kubectl /usr/local/bin/
After completing the setup, verify that kubectl is installed correctly by checking its version:
kubectl version --client
This command should output the version of the installed kubectl client, confirming a successful installation.
Congratulations! You have successfully installed Kubectl. Thanks for using this tutorial for installing the Kubectl on the Ubuntu 24.04 LTS system. For additional help or useful information, we recommend you check the Kubectl website.