How to install Kubernetes on Ubuntu 18.04 Bionic Beaver Linux


The objective is to install Kubernetes on Ubuntu 18.04 Bionic Beaver Linux

Operating System and Software Versions

  • Operating System: – Ubuntu 18.04 Bionic Beaver Linux
  • Software: – Kubernetes v1.10.0


Privileged access to your Ubuntu System as root or via sudo command is required.


In this guide we will be configuring the simplest possible Kubernetes cluster consisting of two nodes. The first node with hostname kubernetes-master will act as the master node.

The second node with hostname kubernetes-master also running Ubuntu 18.04 will be a slave node simply joining the Kuberneets cluster. Once we get the Kubernetes cluster up and running as a proof of concept we will deploy a Nginx server container.


  • # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
  • $ – requires given linux commands to be executed as a regular non-privileged user

Other Versions of this Tutorial

Ubuntu 20.04 (Focal Fossa)


Install Docker

The first step is to install docker on every node. This includes both, master and slave nodes. Execute the following linux command to install docker on all your Kubernetes nodes:

$ sudo apt install

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

$ sudo systemctl enable docker

Install Kubernetes

At this stage we are ready to install Kubernetes. Once again we need to install Kubernetes on all nodes. Execute the below command on all nodes (master & slave) to install Kubernetes:

Let’s start by adding the Kubernetes signing key:

$ curl -s | sudo apt-key add

Next, add the Kubernetes repository and install Kubernetes:

NOTE: At the time of writing only Ubuntu 16.04 Xenial Kubernetes repository is available. Replace the below xenial with bionic codename once the Ubuntu 18.04 Kubernetes repository becomes available.

$ sudo apt-add-repository "deb kubernetes-xenial main"
$ sudo apt install kubeadm 

Kubernetes will refuse to function if your system is using swap memory hence we need to disable swap memory on all your nodes (master & slave):

$ sudo swapoff -a

Next, ensure that all your nodes have a unique host name. Thus, if you have not done so yet set hostname to your nodes. In our scenario we will set the master node with the kubernetes-master hostname:

$ sudo hostnamectl set-hostname kubernetes-master

and the slave node with the kubernetes-master hostname:

$ sudo hostnamectl set-hostname kubernetes-slave

Lastly, it is worth to mention that all your nodes should have an accurate time and date, otherwise you will run into trouble with invalid TLS certificates.

Initialize Kubernetes master Server

Now we are ready to initialize the Kubernetes master node. To do so execute the following linux command on your master node:

kubernetes-master:~$ sudo kubeadm init --pod-network-cidr=
Kubernetes on Ubuntu 18.04

Kubernetes on Ubuntu 18.04 master node is now initialized.

Take a note of the entire kubeadm join command from the bottom of the above Kubernetes master node initialization output as you will use this command later when joining the Kubernetes cluster with your slave nodes.

Next, as the Kubernetes master node initialization output suggested execute the bellow commands as a regular user to start using Kubernetes cluster:

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

Deploy a pod network

Next step is to deploy a pod network. The pod network is used for communication between nodes within the Kubernetes cluster. For this we will use the Flannel pod network:

kubernetes-master:~$ kubectl apply -f

Depending on your environment it may take few seconds or a minute to bring the entire flannel network up. Use the kubectl command to confirm that everything is up and ready:

kubernetes-master:~$ kubectl get pods --all-namespaces
Kubernetes Flannel pod network deployed on Ubuntu 18.04

Flannel pod network deployed. If successful, you should see your output similar to the one above.

Join Kubernetes Cluster

All should be now ready for our node(s) to join Kubernetes cluster. Use the kubeadm join command retrieved earlier from the Kubernetes master node initialization output to join your Kubernetes cluster:

kubernetes-slave:~$ sudo kubeadm join --token qdjnpd.5glu39uxr92xarsj --discovery-token-ca-cert-hash sha256:ed0684156c718caf425ceae6c85a56c05f7b49037cde3a2f1fd57430a4f58f89
Ubuntu 18.04 Node joins Kubernetes cluster

The slave node has successfully joined our Kubernetes cluster.

On your Kubernetes master node confirm that the node kubernetes-slave is now part of our Kubernetes cluster:

kubernetes-master:~$ kubectl get nodes
List of all joined Kubernetes nodes

List of all joined Kubernetes nodes.

Deploying a service on Kubernetes cluster

As a proof of concept we will now deploy a Nginx server into our new Kubernetes cluster. Now, run the following two commands on your master node :

kubernetes-master:~$ kubectl run --image=nginx nginx-server --port=80 --env="DOMAIN=cluster"
kubernetes-master:~$ kubectl expose deployment nginx-server --port=80 --name=nginx-http

You should now see a new nginx docker container deployed on your slave node:

kubernetes-slave:~$ sudo docker ps
Deploy service on Kubernetes Cluster on Ubuntu 18.04

New docker Nginx container is up and running on Kubernetes slave node.

To confirm that our new Nginx service is up and running list all available services on your master node and use the curl command to perform a HTTP request on your CLUSTER IP:

kubernetes-master:~$ kubectl get svc
kubernetes-master:~$ curl -I
Nginx Service on Ubuntu 18.04 Kubernetes cluster

Nginx Service on Ubuntu 18.04 Kubernetes cluster