How to Install Kubectl on Ubuntu 24.04

Kubectl is a robust command line tool that acts as a bridge between you and the Kubernetes clusters. With Kubectl, you can create and manage your Kubernetes resources, such as services, deployments, pods, and more. You can also check for the logs, status, and configuration of your Kubernetes cluster resources, and scale your applications up and down with Kubectl. Further, you can troubleshoot problems, debug your applications, and run commands inside the containers within your pods by using Kubectl.

On Ubuntu’s latest LTS release (Ubuntu 24.04), you can install Kubectl without an issue and manage your Kubernetes clusters right from the terminal. This blog provides a complete guide on how to install Kubectl on Ubuntu 24.04.

How to Install Kubectl on Ubuntu 24.04

Kubectl can be installed on Ubuntu 24.04 from:

How to Install Kubectl on Ubuntu 24.04 from Snap Store

The easiest method to install Kubectl on Ubuntu 24.04 is using the Snap Store. This method may not install Kubectl’s latest version on the system but ensures you get the version close to the latest one. Snap Store is preinstalled on the Ubuntu system, including the newest release, Ubuntu 24.04. However, in case you accidentally remove it, run the below-given command to install it:

sudo apt install snapd -y

You can then install Kubectl on Ubuntu 24.04 from the Snap Store using the following command:

sudo snap install kubectl --classic
Install Kubectl on Ubuntu 24.04 a

To ensure Kubectl is successfully installed on Ubuntu from the Snap Store, use the below-given command:

kubectl version --client
Install Kubectl on Ubuntu 24.04 b

Note: You can easily remove Kubectl from Ubuntu installed through Snap Store using the following command:

sudo snap remove kubectl
Install Kubectl on Ubuntu 24.04 c

How to Install Kubectl on Ubuntu 24.04 from Kubernetes Repository

If you want to install Kubectl’s latest release on Ubuntu 24.04, add the official Kubernetes repository and install Kubectl from the apt package manager. The step-by-step process to install Kubectl from the Kubernetes repository is provided below:

Step 1: Download the Public Sign-in or GPG Key

First, verify the authenticity of the Kubernetes repository by downloading the public sign-in or gpg key on Ubuntu from the following command:

curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.30/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
Install Kubectl on Ubuntu 24.04 d

Step 2: Add Kubernetes Repository

Now, add the Kubernetes repository to the Ubuntu’s repository list using the below-given command:

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
Install Kubectl on Ubuntu 24.04 e

Step 3: Update Ubuntu Repository

Once you add the Kubernetes repository, update the Ubuntu repository using the following command to ensure the newly added repository is successfully added:

sudo apt update
Install Kubectl on Ubuntu 24.04 f

Step 4: Install Kubectl on Ubuntu

Once you successfully update the repository, it’s time to install Kubectl on Ubuntu from the apt package manager using the following command:

sudo apt install kubectl -y
Install Kubectl on Ubuntu 24.04 g

Step 5: Confirm Kubectl Installation

To confirm Kubectl installation on Ubuntu from the apt package manager, you can use the following command:

kubectl version --client
Install Kubectl on Ubuntu 24.04 h

Note: In case you no longer need Kubectl on Ubuntu, use the following command to remove it from the system completely with all dependencies:

sudo apt autoremove kubectl -y
Install Kubectl on Ubuntu 24.04 i

How to Install Kubectl on Ubuntu 24.04 from Kubectl Binary File

Kubernetes developers have also released a Kubectl binary file that can be downloaded and made executable to run on the system. You can follow the below-given steps to install Kubectl on Ubuntu 24.04 from the Kubectl binary file:

Step 1: Download the Kubectl Binary File

First, download the Kubectl latest release on Ubuntu from the terminal based on your architecture. For the AMD64 Ubuntu system, you can use the following command to download the Kubectl binary file:

curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
Install Kubectl on Ubuntu 24.04 j

Note: For ARM64, replace amd64 with arm64 in the above command.

Step 2: Validate the Binary (Optional)

You can validate your Kubectl binary file by first downloading the checksum file for Kubectl using the following command:

curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl.sha256"
Install Kubectl on Ubuntu 24.04 l

Then validate the downloaded Kubectl binary file against the checksum file using the following command:

echo "$(cat kubectl.sha256)  kubectl" | sha256sum --check
Install Kubectl on Ubuntu 24.04 m

The OK output returned, as a result, ensures that your Kubectl binary file is successfully validated. 

Step 3: Make the Kubectl Binary File Executable

Now, use the following chmod command to make the downloaded Kubectl binary file executable on Ubuntu: 

sudo chmod +x kubectl
Install Kubectl on Ubuntu 24.04 m

Step 4: Move the Kubectl Binary File to the Bin Directory

Then move the Kubectl binary file to the /usr/local/bin location using the following command so that the system will detect the file:

sudo mv kubectl /usr/local/bin
Install Kubectl on Ubuntu 24.04 n

Step 5: Confirm Kubectl Installation

To confirm Kubectl installation, first close the current terminal session and open it again. Then use the below-given command to ensure Kubectl is successfully installed on Ubuntu:

kubectl version --client
Install Kubectl on Ubuntu 24.04 o

Note: To remove Kubectl from Ubuntu installed through the binary method, simply remove the file from bin directory using the following command:

sudo rm /usr/local/bin/kubectl
Install Kubectl on Ubuntu 24.04 p

Conclusion

Kubectl is a robust command line tool that manages your Kubernetes cluster directly from the terminal. You can install Kubectl on Ubuntu 24.04 from the Snap Store, Kubernetes repository, and Kubectl binary file. The Snap Store method is simple and allows you to install Kubectl on Ubuntu through the “snap install kubectl –classsic” command. 
For the Kubernetes repository method, you have to add the sign-in key and repository to the Ubuntu system. After that, you can install Kubectl from the “apt install kubectl” command. For the Kubectl binary file method, download the binary file from the official Kubernetes website, and make the file executable using the chmod command. Then move the file to /usr/local/bin location, close and reopen the terminal to confirm the Kubectl installation on Ubuntu.