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




best linux distros programmers
Linux distros have long been a favorite among programmers since the rise in popularity of the OS in the nineties. Programmers are technical by nature, and Linux distros appeal to that technical nature. Let's discuss why Linux is a great desktop OS for programmers and developers, and find out best distros suitable for them.
screen capture apps linux
Do you want to make a video tutorial for YouTube or show-off your epic victory royale to your friends? Look no further — as we have compiled the 10 Best Screen Capturing Software for Linux. Whether you need to record your desktop screen or take a simple screenshot, FOSSLinux has got your back.
Free up hard disk space ubuntu
Hard disk space can easily get filled up with cached package files, old kernels, and other obsolete files that occupy unwanted hard disk space. Here are top five best and safer ways to clean and free up hard disk space in Ubuntu. We show you Terminal and GUI way of cleaning up system.