How to install and configure Kubernetes on Ubuntu

Kubernetes is an open-source system used for automating deployment, scaling, and management of containerized applications.

Kubernetes is an open-source system used for automating deployment, scaling, and management of containerized applications. It’s also called K8s which is a short abbreviation comes by replacing the remaining eight letters “ubernete” with 8.

Installing Kubernetes on Ubuntu

In this tutorial, we are going to show you how to install Kubernetes and configure it on the Ubuntu system. For this tutorial you will need two Ubuntu nodes (machines) with the following minimum configurations:

  • Node 1: Will be a master node (CPU of 2 Cores, 2 GB RAM).
  • Node 2: Will be a slave node (CPU of 1 Core, 1GB RAM).

Before starting the installation process, you will need to ensure that your machine is updated. You can use the following commands:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade

Set hostname for your Nodes

Step 1. On your master node, use the following command:

sudo hostnamectl set-hostname kubernetes-master

Step 2. On your slave node, use the following command:

sudo hostnamectl set-hostname kubernetes-slave

It’s highly recommended for both the nodes to have an accurate time and date to get valid TLS certificates.

Docker Installation

Perform the following steps on Master as well as slave.

Step 1. Install Docker using the following command.

sudo apt install

Step 2. Verify your installation you can use:

docker --version

Docker Version
Docker Version

Step 3. By default, the docker service is not enabled. So, once the installation completes successfully, execute the following command on both nodes to enable the docker service.

sudo systemctl enable docker

Enable Docker Service
Enable Docker Service

Kubernetes Installation

Perform the following steps on Master as well as slave.

Step 1. Install curl package using the next command.

sudo apt install curl

Step 2. Add the Kubernetes signing key.

curl -s | sudo apt-key add

Add Kubernetes Signing Key
Add Kubernetes Signing Key

Step 3. Add the Kubernetes repository.

sudo apt-add-repository "deb kubernetes-xenial main"

Note that at the time of writing this tutorial only the Xenial Kubernetes repository is available so it will be the one we will use for our installation.

Step 4. Verify your installation, use the command:

kubeadm version

Kubeadm Version
Kubeadm Version

Step 5. Before installing Kubernetes, make sure that your system is not using the swap memory because Kubernetes will refuse to operate if your Ubuntu is using the swap memory.

Disable the swap memory:

sudo swapoff -a

Step 6. Install Kubernetes.

sudo apt install kubeadm

Kubernetes Master Server Initialization

Step 1. On your master node, use the next command to initialize the Kubernetes master node.

sudo kubeadm init --pod-network-cidr=

Initialize Kubernetes
Initialize Kubernetes

Take a copy from the last line “kubeadm join –token edvbbv.51hy5e2hgaxr1b4h –discovery-token-ca-cert-hash sha256:01db7c5913e363c099dc7a711550b8399c41f7cc92bda6b5ff06d6b8382a73e2” in the previous screenshot as we will be using it in the slave node to make it join the cluster.

Step 2. Also, as per the previous output its recommended to use the following commands to start using the Kubernetes cluster.

mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

Pod Network Deployment

To enable communication between cluster nodes, we have to deploy a pod network.

Step 1.  On master node, use the following command to deploy a pod network.

kubectl apply -f

Deploy Pod Network
Deploy Pod Network

Step 2.  On the master node, ensure that everything is up and running.

kubectl get pods --all-namespaces

Check Status
Check Status

Join the Kubernetes Cluster

For now, everything should be ready for the master and slave nodes to join the Kubernetes Cluster.

Step 1. On the slave node and to let the slave node join the cluster, use the command copied earlier from the output of Kubernetes initialization step, which should look something like this:

sudo kubeadm join --token edvbbv.51hy5e2hgaxr1b4h --discovery-token-ca-cert-hash sha256:01db7c5913e363c099dc7a711550b8399c41f7cc92bda6b5ff06d6b8382a73e2

Join Kubernetes Cluster
Join Kubernetes Cluster

Step 2. On the master node, check if the slave node has joined the cluster:

kubectl get nodes

Congratulations, you just have created the Kubernetes cluster and everything should be ready to move on and deploy any service you need (like Apache container or Nginx server) to start using your cluster.

I hope you have enjoyed this tutorial and in case you have faced any difficulties during the installation leave a comment, and we will be glad to help you.

Hend Adel
Hi! I'm Hend Adel, a freelancer technical geek with successful experience in Database, Linux and many other IT fields. I help to build solutions to suit business needs and creating streamlined processes. I love Linux and I'm here to share my skills via FOSS Linux! Thanks for reading my article.


  1. good, but missing ` apt-gert update` step after reposittory was added, then mising the very important installation step like – `sudo apt install kubeadm -y`


Please enter your comment!
Please enter your name here




The 10 Best Linux Server Distros For Home And Businesses

By the year 2020, it is estimated that there are close to 600 Linux distributions in the market. It includes both servers and Desktop versions; therefore, if you are looking for lightweight Linux distribution for your old PC or a reliable desktop version for employees in your organization, you may be overwhelmed with the number of choices for finding one for your use.

How to list the installed Packages on Ubuntu

It is only natural to start installing more and more software on your Ubuntu PC once you start using it. Similarly, it is also natural to lose track of the different packages that you have installed on your system. Eventually, you may be overwhelmed with the number of packages in your system and with the ones you hardly used.

How to configure the Ubuntu Firewall (UFW)

A properly configured firewall is a crucial part of establishing preliminary system security. Keeping this in mind, here we will go over how to configure the firewall on your Ubuntu PC.

How to install and use Zoom on Ubuntu

If you work from home or hold meetings with other people remotely, then you have probably heard of Zoom. It is one of the popular video conferencing software app available today.

How to Restart Networking on Ubuntu

Sometimes resetting your Ubuntu network is required to apply some network configurations like changing your IP from Automatic DHCP to static one. Restarting the network is not a big deal, but should be done carefully.

How to install Chrome and Chromium Browser on Pop!_OS

By default, Pop!_OS comes with Mozilla Firefox Browser installed to help you browse the internet. It is a reliable web browser covering almost all the features and functionalities you need. However, working with Firefox is noticeably different compared to Google Chrome, especially from the speed point of view. Google Chrome is a tad quicker than Firefox.


Linux is growing faster than ever. As per the latest report, there is a drop in the Windows 10 market share for the first time, and Linux's market share has improved to 2.87% this month. Most of the features in the list were rolled out in the Pop OS 20.04. Let's a detailed look into the new features, how to upgrade, and a ride through video.
Elementary OS 5.1 Hera has received a point release with a handful of new features and bug fixes, and we will be reviewing the significant changes in this article. For those new to elementary OS, this Ubuntu-based Linux distribution uses their inhouse built Pantheon desktop environment and AppCenter.

5 Best ways to encrypt files in Linux

Privacy is something that almost all of us have concerns about. Many people switch over to Linux because of its better privacy features. In this time, where many people believe (quite rightly so) that privacy doesn't exist anymore, Linux provides a ray of hope. Distributions like Tails OS are specifically designed for that purpose.

Top 5 Linux Distros for Windows Users

When Microsoft initially released Windows 7 in October 2009, the software giant committed to providing ten years of support for its popular operating system.  The much-maligned Microsoft was true to their word, support for Windows 7 ended just yesterday a little over ten years after its release.

What is the difference between Linux and Unix?

When discussing Linux and Unix with average users, it's not uncommon that they will sometimes mistakenly interchange the terms Linux and Unix.  The two are not the same.  Though they share similarities in their overall structures and toolkits, they are decidedly not the same.

Guide to watching Disney+ on Linux

Disney Plus or Disney+ is an on-demand entertainment streaming service in which you should see the content produced by Disney Studios, Star Wars, Marvel, Pixar, and National Geographic. The service was launched on the 12th of November 2019.