How to install Kubernetes with Kubeadm

How to install Kubernetes with Kubeadm

Create the VM

These instructions were tested using a VirtualBox VM, but in theory they should be similar for a bare metal deployment. (You can find instructions for creating a VM here.) A few things to note about VMs:

Allocate at least 2 vCPUs, even if you are overusing your resources; There are a few pieces to this example that won’t start with just one.

Try to allocate at least 4096 MB of RAM and 20 GB of drive space.

You must have Ubuntu 20.04 or later installed.

Read Also – What is Linux Operating System?

Set the default network adapter to connect to a “Bridged Adapter” to enable traffic between the VM and the host machine.

prepare vm

There are a few things you need to do to prepare the VM. Specifically, you’ll need to turn off swap, change some configuration settings, and make sure you have the prerequisite libraries installed. To do this, follow these steps

1)Change to root:

sudo su

2)Turn off swap: To do this, you will first need to turn it off directly:

swapoff -a

. then comment out the reference to swap in /etc/fstab.  Start by editing the file:

vi /etc/fstab

Then comment out the appropriate line, as in:

# /etc/fstab: static file system information.
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
# <file system> <mount point>   <type>  <options>    <dump>  <pass>
# / was on /dev/sda1 during installation
UUID=1d343a19-bd75-47a6-899d-7c8bc93e28ff /            ext4 errors=remount-ro 0    1
# swap was on /dev/sda5 during installation
#UUID=d0200036-b211-4e6e-a194-ac2e51dfb27d none         swap sw 

Now configure iptables to receive bridged network traffic. First edit the sysctl.conf file:

vi /etc/ufw/sysctl.conf

And add the following lines to the end:

net/bridge/bridge-nf-call-ip6tables = 1
net/bridge/bridge-nf-call-iptables = 1
net/bridge/bridge-nf-call-arptables = 1
  1. Reboot so the changes take effect.
  2. Install ebtables and ethtool:
sudo su
apt-get install ebtables ethtool

Reboot once more.

Kubeadm Install Process

OK, now we’re ready to go ahead and do the install.  For the full details on this process, you can see the documentation, but here’s the quick and dirty version:

1.Install Docker:

sudo su

apt-get update
apt-get install -y

Install HTTPS support components (if necessary):

apt-get update 
apt-get install -y apt-transport-https

Install Curl (if necessary):

apt-get install curl

Retrieve the key for the Kubernetes repo and add it to your key manager:

curl -s | apt-key add -

Add the kubernetes repo to your system

cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
deb kubernetes-xenial main

Actually install the three pieces you’ll need, kubeadm, kubelet, and kubectl:

apt-get update
apt-get install -y kubelet kubeadm kubectl

Installing Kubernetes with kubeadm recap:

So at this point you know how to:

  1. Prepare a VM for Kubeadm
  2. Install Kubeadm
  3. Deploy a Kubernetes cluster
  4. Deploy a sample application on a Kubernetes application
  5. Remove the sample application
  6. Remove the cluster

In future articles, we will talk about other features like creating custom applications and adding additional nodes to the cluster. You can also check out our previous tutorial on creating a Kubernetes deployment, or spend an hour learning the basics of Kubernetes with our free Kubernetes mini-boot camp. Do you expect this project to grow, and you may need help managing Kubernetes? Check out our Kubernetes support options.

Devopslover Youtube Channel
How to install Kubernetes with Kubeadm, How to install Kubernetes with Kubeadm How to install Kubernetes with Kubeadm How to install Kubernetes with Kubeadm How to install Kubernetes with Kubeadm How to install Kubernetes with Kubeadm How to install Kubernetes with Kubeadm How to install Kubernetes with Kubeadm
Mahesh Wabale
Latest posts by Mahesh Wabale (see all)

Leave a Comment