In this tutorial, we will show you how to install Kubernetes on Ubuntu 20.04 LTS. For those of you who didn’t know, Kubernetes is a free and open-source container management system that provides a platform for deployment automation, scaling, and operations of application containers across clusters of host computers. With Kubernetes, you can freely make use of the hybrid,on-premise, and public cloud infrastructure in order to run deployment tasks of your organization.
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 through the step by step installation Kubernetes on a Ubuntu 20.04 (Focal Fossa) server.
Install Kubernetes on Ubuntu 20.04 LTS Focal Fossa
Step 1. First, make sure that all your system packages are up-to-date by running these following
apt commands in the terminal.
Step 2. Installing Docker.
Follow the command to install Docker CE on Ubuntu 20.04:
Once the Docker is installed ensure that it is enabled to start after reboot:
You can verify the Docker installation:
Now we add the Kubernetes signing key:
curl-shttps://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add
Next, we’ll add the Kubernetes package repository:
sudoapt-add-repository"deb http://apt.kubernetes.io/ kubernetes-xenial main"
After that, run following command to install Kubernetes:
Running Kubernetes requires that you disable swap:
To permanently disable swap, comment out or remove the swap line on /etc/fstab file:
# / was on /dev/sda2 during curtin installation
#/swap.img none swap sw 0 0
Now give hostnames to each node. In our scenario, we’re using the hostnames master-node and master-node to easily differentiate our hosts and identify their roles:
First, enter the following command on your master node:
Next, run those three commands on the master node:
Next step is to deploy a pod network. Run the following two commands on the master node:
You can use the kubectl command to confirm that everything is up and ready:
Now our cluster is ready to have the worker nodes join. Use the
kubeadm join command retrieved earlier from the Kubernetes master node initialization output to join your Kubernetes cluster:
Confirm that master-node is now part of our Kubernetes cluster with this command:
In these steps we are ready to deploy a service into the Kubernetes cluster. Run the following two commands on your master node:
You should now see a new Nginx docker container deployed on your worker node:
Finally, you can see a running list of all available services running in your cluster with the following command, issued from the Kubernetes master node:
Congratulations! You have successfully installed Kubernetes. Thanks for using this tutorial for installing Kubernetes on Ubuntu 20.04 LTS Focal Fossa systems. For additional help or useful information, we recommend you to check the official Kubernetes website.