Install Kubernetes in Ubuntu 20.04

Install Kubernetes in Ubuntu

Single or Multi-node cluster installation

Prerequisites

  • 1 or more Linux servers running Ubuntu 20.04
  • Access to a user account on each system with sudo or root privileges
  • The apt package manager, included by default
  • Command-line/terminal window (Ctrl–Alt–T)

Steps to Install Kubernetes

Set up and config Docker

  • sudo apt install apt-transport-https
  • sudo apt-get install docker.io
  • docker version
  • sudo systemctl enable docker
  • sudo systemctl status docker

Set up and config Kubernetes

  • Update the package list with the command:

sudo apt-get update

  • Install curl

sudo apt-get install curl

  • Enter the following to add a signing key:

sudo curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add

  • Add software repositories

echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" >> ~/kubernetes.list

sudo mv ~/kubernetes.list /etc/apt/sources.list.d

  • Again update the package list 

sudo apt-get update

  • Install kubernetes tools

sudo apt-get install -y kubeadm kubelet kubectl kubernetes-cni

  • Disable the swap memory on each server

sudo swapoff -a

  • Initialize kubernetes in multi-node cluster

sudo kubeadm init

  • Initialize kubernetes in single-node cluster

sudo kubeadm init --ignore-preflight-errors=NumCPU

  • Finish setup and check kubernetes

mkdir -p $HOME/.kube

  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config

  sudo chown $(id -u):$(id -g) $HOME/.kube/config


Remove Kubernetes Completely

sudo kubeadm reset

sudo apt-get purge kubeadm kubectl kubelet kubernetes-cni kube* 

sudo apt-get autoremove 

sudo rm -rf ~/.kube


Comments