How To Install Kubernetes on Ubuntu

How To Install Kubernetes on Ubuntu

Written by Adam. R on Sep 6th, 2021 Views Report Post

Software Requirement:

2 or more Ubuntu 18.04 servers Access to a sudo or root privileged user account on each device The apt package manager.

Swap disabled. You MUST disable swap in order for the kubernetes to work properly.


Installation Procedure:

Step 1. Installing Docker

On both master and slave nodes, the following must be performed.

  1. Docker's installation is the first thing to do. Login into the server to do this and export the command.
sudo apt-get install docker.io

sudo apt-get install docker.io.png In order to continue the installation, you will be asked to choose a Y/N option. Please enter Y to continue, then press Enter and your machine will be configured with Docker. 2. The installation can also be checked by using the following instruction, and the Docker version number:

docker --version 

docker --version.png You must add your user to the docker community once Docker is installed (otherwise you must carry out all the sudo docker commands which could lead to security problems). 3. Use the command to connect your user to the docker group:

sudo usermod -aG docker $USER 

sudo usermod -aG docker $USER.png Log out and log in, so that adjustments come into effect. 4. Launch and activate the docker daemon with the commands:

sudo systemctl start docker 
sudo systemctl enable docker 

sudo systemcl start docker.png


Step 2: Installing Kubernetes

Now, install Kubernetes on both the machines. As Kubernetes is downloaded from a non-standard repository, it is essential for the software to be authentic. This is achieved with the addition of a signing key.

  1. Add the GPG Kubernetes key with the command:
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add 

curl OK packages cloud.png In order to continue the installation, you will be asked to choose a Y/N option. Please enter Y, then press Enter. You will then install the Curl utility on your device. 3. Sometimes Kubernetes is not added in default repository. To add the Xenial Kubernetes repository, run the following command on both nodes:

sudo apt-add-repository "deb http://apt.kubernetes.io/ kubernetes-xenial main" 

kubernetes appt repostiroy.png 4. Installing Kubeadm (Kubernetes Admin) on both nodes by command is the final stage of the installation process:

sudo apt-get install kubeadm kubelet kubectl 

apt get install kubeadm.png Run the below command to check whether the versions of the components installed are compatible with each other.

sudo apt-mark hold kubeadm kubelet kubectl

apt-mark kubeadm.png In order to continue the installation, you will be asked to choose a Y/N option. Please enter Y to continue, then press Enter. Kubeadm will then be installed on your device.

  1. You can also check Kubeadm's version number and verify the installation using the following command:
kubeadm version 

kubeadm version.png Repeat for each server node.

Ensure that on each computer you install the same package version. Instability can arise from various versions. This mechanism also prevents Kubernetes from being updated automatically.

Now just set up your network!

If you found this usful then please comment and follow me! Also check out my website where I also post everything from here

Comments (0)