How To Install Kubernetes on Ubuntu 18.04 LTS

Install Kubernetes on Ubuntu 18.04 LTS

In this tutorial, we will show you how to install Kubernetes on Ubuntu 18.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 of Kubernetes on a Ubuntu 18.04 (Bionic Beaver) server.

Install Kubernetes on Ubuntu 18.04 LTS Bionic Beaver

Step 1. First, make sure that all your system packages are up-to-date by running these following apt commands in the terminal.

sudo apt update
sudo apt upgrade

Step 2. Installing Docker.

Now we have to install Docker because Docker images will be used for managing the containers in the cluster. Run the following commands:

sudo apt install

Once the Docker is installed ensure that it is enabled to start after reboot:

sudo systemctl enable docker 
sudo systemctl start docker

Step 3. Installing Kubernetes on Ubuntu.

First, add the Kubernetes signing key on both the nodes:

curl -s | sudo apt-key add

Next, add Xenial Kubernetes Repository on both the nodes:

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

Step 4. Installing Kubeadm.

The final step in the installation process is to install Kubeadm on both the nodes through the following command:

sudo apt install kubeadm

Check the version number of Kubeadm and also verify the installation through the following command:

kubeadm version

Step 4. Kubernetes Deployment.

First, disable swap memory (if running) on both the nodes:

sudo swapoff -a

Next, give hostnames to each node:

sudo hostnamectl set-hostname master-node
sudo hostnamectl set-hostname slave-node
  • Initialize Kubernetes on the master node:
sudo kubeadm init --pod-network-cidr=
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

You can check the status of the master node by running the following command:

kubectl get nodes
  • Deploy a Pod Network through the master node:

A pod network is a medium of communication between the nodes of a network:

sudo kubectl apply -f

Use the following command in order to view the status of the network:

kubectl get pods --all-namespaces

Now when you see the status of the nodes, you will see that the master-node is ready:

sudo kubectl get nodes

Next, add the slave node to the network in order to form a cluster:

sudo kubeadm join --token 06tl4c.oqn35jzecidg0r0m --discovery-token-ca-cert-hash sha256:c40f5fa0aba6ba311efcdb0e8cb637ae0eb8ce27b7a03d47be6d966142f2204c

Now when you run the following command on the master node, it will confirm that two nodes, the master node, and the server nodes are running on your system:

sudo kubectl get nodes

Congratulations! You have successfully installed Kubernetes. Thanks for using this tutorial for installing Kubernetes on Ubuntu 18.04 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!