How To Install Kubernetes on Ubuntu 22.04 LTS
In this tutorial, we will show you how to install Kubernetes on Ubuntu 22.04 LTS. Kubernetes (also known as K8s) is an open-source container orchestration platform that automates the deployment, scaling, and management of containerized applications. It was originally developed by Google and is now maintained by the Cloud Native Computing Foundation (CNCF).
Kubernetes united the lands of developers and operators, bringing forth a new era of container orchestration. With Kubernetes, gone were the days of manual toil – deploying and scaling microservices across vast fleets of servers was now automated with ease. Applications became self-healing, seamlessly recovering from failures without human intervention.
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 Kubernetes on Ubuntu 22.04 (Jammy Jellyfish). 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 22.04, 20.04, and any other Debian-based distribution like Linux Mint.
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies for Kubernetes.
- SSH access to the server (or just open Terminal if you’re on a desktop).
- A
non-root sudo user
or access to theroot user
. We recommend acting as anon-root sudo user
, however, as you can harm your system if you’re not careful when acting as the root.
Install Kubernetes on Ubuntu 22.04 LTS Jammy Jellyfish
Step 1. First, make sure that all your system packages are up-to-date by running the following apt
commands in the terminal.
sudo apt update sudo apt upgrade sudo apt install wget apt-transport-https gnupg2 software-properties-common
Step 2. Installing Docker.
Kubernetes uses Docker as its container runtime. We need to install Docker before installing Kubernetes. By default, Docker is not available on Ubuntu 22.04 base repository. Now run the following command below to add the Docker repository to the system:
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list
Next, import the GPG key to your system:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
After the repository is enabled, now install the latest version of the Docker package using the below command:
sudo apt update sudo apt install docker-ce docker-ce-cli containerd.io docker-compose-plugin
You can verify that Docker is installed and about the current version:
docker -v
After successfully installed, enable Docker (to start automatically upon system boot), start, and verify the status using the commands below:
sudo systemctl enable docker sudo systemctl start docker sudo systemctl status docker
For additional resources on installing and managing Docker, read the post below:
Step 3. Installing Kubernetes on Ubuntu 22.04.
After installing Docker, we can proceed with installing Kubernetes. First, we import the Kubernetes signing key using the following command:
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
Next, add the Kubernetes repository to the Ubuntu package sources list using the following command:
sudo apt-add-repository "deb http://apt.kubernetes.io/ kubernetes-xenial main"
After that, update the package list again and install Kubernetes using the following command below:
sudo apt update sudo apt install kubeadm kubelet kubectl
Step 4. Configure Kubernetes.
After installing Kubernetes, we need to configure it to make it work properly. Now initialize the Kubernetes cluster using the following command:
sudo kubeadm init
Once initialization, Kubernetes will provide a command to add nodes to the cluster. Copy this command and save it for future use. Configure kubectl
to access the Kubernetes cluster using the following commands:
mkdir -p $HOME/.kube sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config sudo chown $(id -u):$(id -g) $HOME/.kube/config
Verify that Kubernetes is working by running the following command:
kubectl version
Congratulations! You have successfully installed Kubernetes. Thanks for using this tutorial for installing the Kubernetes management containerized workload on Ubuntu 22.04 LTS Jammy Jellyfish system. For additional help or useful information, we recommend you check the official Kubernetes website.