How to Install Kubernetes on Ubuntu 20.04 (Focal Fossa) part 1

Ahamad Mohammad
4 min readAug 21, 2020

— -

This blog serves as complete guide from setting up virtual machine to set up of Kubernetes (from now on i refer it as k8s) . This blog has two parts , part 1 is configuring Virtual machines. Part 2 is installing & configuring Docker and Kubernetes. I have configured all in one Laptop as Host and used Virtual Box to set upk8s environment.
My laptop configuration
Windows 10 Pro
Intel core i7–4800MQ
Topology of Kubernetes Cluster:
We are going to create one Master node (Control plane) and two nodes.
VM Specifications:
Minimum of 2 GB RAM (for Master node you can use 4GB )
2 Core (2 vCPUs) (Minimum 2 cores are needed for k8s set up, otherwise k8s would not install)
25 GB Free Space

— -

Creating Virtual Machine
we are going to download Oracle virtual box and create a virtual machine and clone it.

Install Virtual Box
Download and Install Virtual Box from . Installation is pretty simple, double click on executable and rest of the installation steps are self explanatory.

Create a VM using instructions mentioned in these links , virtualbox guest additions is a convenience package and its optional to install.
Restart the VM once installation is complete
Network set up for Kubernetes:
By default Virtual Box VM have NAT network adapter turned on, we need to turnoff that adapter. Set up two adapters ,one Bridged Network and one Host Network .

Bridged network set up
click on Oracle Virtual Box VM Manager → VM →settings →Network and choose “Enable Network Adapter” and select “Bridged Adapter” and leave all defaults.

Host only Network set up
Click on Oracle Virtual Box VM Manager →File →Host Network Manager
choose radio button “ configure Adapter manually”
IPv4 Address
IPv4 Netmask
Do not define DHCP server in the DHCP tab,leave the default set up.

Enable Host only Adapter for the VM

Click Virtual Box VM Manager → VM →settings →Network
Click Adapter 2 and choose below options
Attached to : Host-Only Adapter
Name : Virtual Box Host-only Ethernet Adapter #2
Disable NAT adapter in VM:
Click Virtual Box VM Manager → VM →settings →Network
Click Adapter 1 and unselect “Enable Netwrok Adapter” (Make sure its NAT adapter)

Make static address changes permanent
Start the virtual Machine
Open terminal window
Edit netplan file “$sudo vi /etc/netplan/01-network-manager-all.yaml” add below lines ,pay attention indentation as YAML is sensitive to indentation.

renderer: NetworkManager
dhcp4: no
addresses: []
addresses: [,]

run below command to try the changes made and apply them

$sudo netplan try
Do you want to keep these settings?
Press ENTER before the timeout to accept the new configuration

press Enter …
$sudo netplan apply
reboot the box

clone virtual machines for node2 and node3
start cloned VM and run below steps to set host name and IP address.
once VM is started open terminal,run hostnamectl


if you need to change host name , use below command
$ sudo hostnamectl set-hostname xxxx

Edit netplan file “$sudo vi /etc/netplan/01-network-manager-all.yaml” and modify the IP address in my case i modified to and
Edit /etc/hosts file and make entries for all hosts.Add the following entries in /etc/hosts files on each node, ahamad-virtualbox1 ahamad-virtualbox4 ahamad-virtualbox9

reboot the box

Configure SSH

Install open SSH server
$sudo apt-get install openssh-server

Generate Keys

Copy Keys to other nodes
$ssh-copy-id ahamad@

Verify the connection by connecting through SSH
$ssh ‘ahamad@’
you will get terminal view to .

$exit ( this will bring you back to your VM environment)
repeat the above two steps for all other nodes.
Kubernetes needs root privileges, configure SSH for root

$ sudo -i
Set the root password (password for the root user).
# passwd
Edit the SSH server configuration file.
# vi /etc/ssh/sshd_config
Add the following line to this file,usually you will see like like “#PermitRootLogin prohibit-password” you can add the line below this
PermitRootLogin yes

Restart the SSH server daemon.
# /etc/init.d/ssh stop
# /etc/init.d/ssh start

Generate keys

#ssh-keygen -t rsa
accept default location for rsa file. This will create a file /root/.ssh/

Copy the public key to be able to login remotely via SSH as root
#ssh-copy-id -i /root/.ssh/

make the public key authorized
#cat /root/.ssh/ >> /root/.ssh/authorized_keys

Verify whether you can log in as root
#ssh root@

copy public key to rest of nodes
# ssh-copy-id -i /root/.ssh/
# ssh root@
# ssh-copy-id -i /root/.ssh/
# ssh root@

At the end of this step all nodes should be able to connect using SSH as root.

This concludes part 1 , in part 2 we will discuss installation of Docker and Kubernetes.