How to Create Multi-node Cluster With Kubeadm?

 How to Create Multi-node Cluster With Kubeadm? 

How to Create Multi-node Cluster With Kubeadm?

DESCRIPTION

  • The installation of Kubernetes cluster with multiple nodes is not problematic.
  • We’ll run the nodes inner side virtual machines from side to side Virtual Box.
  • We may also practice a dissimilar virtualization tool or bare-metal machines.
  • We’ll use the kubeadm tool to set up both the master and the worker nodes,.

Creating the Operating System and necessary packages

  • We needed to download and install Virtual Box.
  • If don’t have it installed previously. We can download it from https://www.virtualbox.org/wiki/Downloads
  • When we have it running, download the CentOS 7 minimal ISO image from           www.centos.org/download.
  • We may also use a different Linux distribution.
  • Validate it’s supported by checking the http://kubernetes.io website.

Making the virtual machine

  • We’ll create the VM for our Kubernetes master.
  • Jump by clicking the new icon in the upper-left corner.
  • Formerly enter “k8s-master” as the name, choose Linux as the Type and Red Hat (64-bit) as the version.
  • By clicking next button, we can set the VM’s memory size and set up the hard disk.
  • Select at least 2GB if we have enough memory.
  • Leave the default options selected when creating the hard disk.

Look in the below case:

  1. Hard disk file type: VDI (VirtualBox Disk Image)
  2. Storage on physical hard disk: Dynamically allocated
  3. File location and size: k8s-master, size 8GB

Arranging the network adapter for the VM

  • After we’re completed creating the VM, we require to configure its network adapter due to the default won’t permit us to run multiple nodes properly.
  • We’ll configure the adapter as it uses the Bridged Adapter mode. This would connect our VMs to the same network our host computer is in.
  • Every VM will develop its own IP address.
  • Make sure the VM is selected in the main Virtual-Box window to arrange the network adapter.
  • At that time click the Settings icon (next to the new icon we clicked before).
  • A window would appear. On the left-hand side, select network and then, in the main panel on the right, select Attached to: Bridged Adapter
  • In the Name drop-down menu, select host machine’s adapter that we use to connect our machine to the network.

Connecting the OS

  • Now we’re ready to run the VM and connect the operating system.
  • Make sure the VM is still selected in the list and click on the Start icon at the top of the VirtualBox main window.
  • Formerly the VM starts up select the start-up disk, VirtualBox will request us what start-up disk to use. Click the icon next to the drop-down list and then find and select the CentOS ISO image we downloaded prior. At that point click Start to boot up the VM.

Creation of a multi-node cluster with kubeadm

  • Starting the install when the VM starts up, a textual menu screen would appear. Use the cursor up key to select the Install CentOS Linux 7 option and press the Enter button.
  • Next a graphical Welcome to CentOS Linux 7 screen will appear, permitting us to select the language we wish to use. Keep the language usual to English.
  • Click the Continue button to get to the main setup screen.
  • Once we click into the VM’s window, our keyboard and mouse would be taken by the VM. Press the key shown at the bottom-right corner of the VirtualBox window the VM is running in to release them.
  • Usually it is the Right Control key on Windows and Linux or the left Command key on MacOS. Click first Installation Destination and then directly click the done button on the screen that appears.
  • Formerly click on Network & Host Name. First enable the network adapter by clicking the ON/OFF switch in the top right corner on the next screen.
  • Then enter the host name into the field at the bottom left, text field to confirm the new host name.
  • Click the Done button in the top-left corner to return to the main setup screen.
  • We have also set the correct time zone. For setting time zone, click Date & Time and then, on the screen that opens, select the Region and City or click location on the map.
  • Return to the main screen by clicking the done button in the top-left corner.

Starting the Installation

    • Click the start installation button in the bottom-right corner.
    • One screen will appear. Set the Setting the hostname and configuring the network adapter
  • Create the root password while the OS is being installed.

Docker and Kubernetes installation

  • First stop two security features after Log into the machine as root.
  • For disabling the SELinux, run the command: # setenforce 0
  • This only disables it temporarily and for permanently disable it we have to edit the /etc/selinux/config file and change the SELINUX=enforcing line to SELINUX=permissive.
  • For disabling the firewall we Run the command: # systemctl disable firewalld && systemctl stop firewalld
  • Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1…
  • Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.

How to make the Kuberentes RPM packages Available to Yum package Manager

  • We’ll include a kubernetes.repo file to the /etc/yum.repos.d/ directory as shown in below listing.
  • # cat < /etc/yum.repos.d/kubernetes.repo
  • [kubernetes]
  • name=Kubernetes
  • baseurl=http://yum.kubernetes.io/repos/kubernetes-el7-x86_64
  • enabled=1
  • gpgcheck=1
  • repo_gpgcheck=1
  • gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg
  • https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg

# yum install -y docker kubelet kubeadm kubectl kubernetes-cni

We’re installing fairly a few packages. Here’s what they are:

  • docker—The container runtime
  • kubelet—The Kubernetes node agent, which will run everything for us
  • kubeadm—A tool for deploying multi-node Kubernetes clusters
  • kubectl—The command line tool for interacting with Kubernetes
  • kubernetes-cni—The Kubernetes Container Networking Interface

We need to manually enable the docker and the kubelet after they’re all installed.

# systemctl enable docker && systemctl start docker

# systemctl enable kubelet && systemctl start kubelet

# swapoff -a && sed -i ‘/ swap / s/^/#/’ /etc/fstab

How to Clone the VM?

We’ve done everything up to this point must be done on every machine we plan to

use in our cluster. If we’re doing this on bare metal for each worker node. If

we’re building the cluster using virtual machines. We end up with three different VMs at this time to clone the VM.

How to shut Down VM?

By running the shutdown command first shut down the VM to clone the machine in virtual Box.

# Shutdown now

Cloning the VM

    • Right-click on the VM in the VirtualBox UI and select Clone.
    • Enter the name for the new machine (for example, k8s-node1 for the first clone or k8s-node2 for the second one).
  • Make sure check the Reinitialize the MAC address of all network cards option, so each VM uses different MAC addresses

Setting up a multi-node cluster with kubeadm

  • Click the Next button and then make sure the Full clone option is selected before clicking next again. Then, click Clone on the next screen.
  • Repeat the process for the VM for the second node and then start all three VMs by selecting all three and clicking the Start icon.

1 thought on “How to Create Multi-node Cluster With Kubeadm?”

Leave a Comment