How To Install Kubernetes on Ubuntu 20.04 LTS

Install Kubernetes on Ubuntu 20.04

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:

Step 3. Installing Kubernetes on Ubuntu 20.04.

Now we add the Kubernetes signing key:

Next, we’ll add the Kubernetes package repository:

After that, run following command to install Kubernetes:

Step 4. Disable swap memory.

Running Kubernetes requires that you disable swap:

To permanently disable swap, comment out or remove the swap line on /etc/fstab file:

Step 5. Set hostnames.

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:

Step 6. Initialize Kubernetes master server.

First, enter the following command on your master node:

Next, run those three commands on the master node:

Step 7. Deploy a pod network.

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:

Step 8. Join the Kubernetes cluster.

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:

Step 9. Deploying a service on Kubernetes cluster.

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.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!