K8S(KUBERNETES) MULTI NODE CLUSTER SETUP

K8S(KUBERNETES) MULTI NODE CLUSTER SETUP

IN this Article i am gonna show you how to set up kubernetes multinode cluster on the top of redhat enterprise linux 8 CLI.

FIRST of all....

WHAT is K8S cluster?

A Kubernetes cluster is a lot of hub machines for running containerized applications. The ace hub is liable for keeping up the ideal condition of the group, for example, which applications are running and which holder pictures they use. Specialist hubs really run the applications and remaining tasks at hand.

No alt text provided for this image


-->prerequisites

1) RHEL8 CLI

2)HOW to useVirtualization tool(like oracle VM)

3)puTTY(for accessing RHEL8 OS via SSH )

4) BASIC idea of how and where we use KUBERNETES

5)BASIC knowledge of DOCKER

-->PC specifications recommended

atleast 8 GB ram

NOW lets start creating ::::::

STEP 1::

Launching Operating System(RHEL8) on the top of Virtualization tool(ORACLE Virtual box in my case)

No alt text provided for this image

-provide atleast 2 gb ram

No alt text provided for this image

--CREATE virtual hard disk

No alt text provided for this image

--HD type VDI

No alt text provided for this image

DYNAMIC allocation

No alt text provided for this image

GIVING size of HD accordingly

No alt text provided for this image

CLICK ON CREATE

--------------------------------------------------------------------------------------------------------------

--NOW right click on three horizontal lines and go to settings

No alt text provided for this image

--ARRANGE boot order like this

No alt text provided for this image

--ATTACH iso file of RHEL8 (which u can get for free from REDHAT official site)

No alt text provided for this image

--ATTACH bridge network card (for both NAT and host connectivity)

No alt text provided for this image

--NOW you are all set click on start (green arrow symbol to begin installation) after clicking OK

JUST BEFORE INSTALLING IT WILLASK FOR FOLLOWING OPTIONS

-select the 8Gib and done

No alt text provided for this image

-DISABLE kdump for so that unwanted ram will not be used

No alt text provided for this image

-MAKE Ethernet ON so that networking start just after VM launch

No alt text provided for this image

-CLICK on Minimal installation for CLI launch

No alt text provided for this image

---------------------------------------------------------------------------------------------------------------

AFTER complete installation power off the machine and check to boot order it should be same as we have set previously, if not set it again then RUN other wise it start installation again.

MOUNTING THE DVD TO THE SYSTEM:::

run the following cmds after login into root account

-mkdir /dvd

-mount /dev/cdrom /dvd

also put this mount command in the

vi /etc/rc.d/rc.local

file to make it permanent otherwise u have to mount it every time you log in

and run

chmod +x /etc/rc.d/rc.local

--NOW we have to configure our newly launched operating system

---------------------------------------------------------------------------------------------------------------

THINGS we have to configure in our system::::

1)yum configuration (for software installation present in AppStream and BaseOS directory of RHEL8 iso file )

2)docker configuration(for containerization )

3)Kubelet configuration(using kubeadm to set up Cluster)

LETS start configuration::::

1)yum configuration:


No alt text provided for this image

--AFTER configuring yum run commands

-yum install net-tools vim to intall some basic commands

- ifconfig to see your ip address

No alt text provided for this image

----------------------------------------------------

2)docker configuration(for containerization )

run cmds-

  • vi /etc/yum.repos.d/docker.repo
No alt text provided for this image

-after creating repo install docker ny running command

yum install docker-ce --nobest

after installation complete run these commands to start and enable it

  • systemctl start docker
  • sstemctl enable docker

-----------------------------------------------------

NOW we will use our special software PUTTY (click me to download)

-we have used putty here because when we access OS as a virtual machine we cannot copy paste the long commands to create files by using purry software we can use it

3)Kubelet configuration(using kubeadm to set up Cluster)

AS kubelet doesnot work with firewall so stop and disable it by the followig commands

-systemctl stop firewalld

-systemctl disable firewalld

-search this on google and click on first link

No alt text provided for this image

-->accessing VM os via putty

-open putty

No alt text provided for this image

-add ip address of your VM-

No alt text provided for this image

-and click on open and provide root login id and password:

No alt text provided for this image

---NOWgo to kubernetes kubeadm docs which we searched on google and copy these commands whick will create repo file for kubelet and past them in the OS command line

which we have accessed through putty(now we will use putty access only)

No alt text provided for this image

-after pasting the commands we get :

No alt text provided for this image

NOW run this command to download commands and other important files for kubernetes:

No alt text provided for this image

BUT this will not work now first we have to make the following changes in the security system:

  • run these commands to go inside selinux config file
No alt text provided for this image
  • make selinux permissive
No alt text provided for this image

---------------------------------------------------------------------------------------------------------------

:::NOW we hve to change the cgroup driver to systemd of docker

by running these commands (click me for link)

this will change your cgroup driver present in docker daemon file to systemd

No alt text provided for this image
No alt text provided for this image

--now run the command to disable swap in fstab

  • vim /etc/fstab
No alt text provided for this image

---LAST and final step set iptables so ip can be seen on bridge

copypaste these commands:

first run

  • yum install iproute-tc

then


No alt text provided for this image

NOW we have t ostart and enable kubelet

No alt text provided for this image

by running these commands:

now reboot the system by command

  • init 0

---------------------------------------------------------------------------------------------------------------

NOW WE GONNA MAKE THREE CLONES OF THIS VM

  • ONE for master node
  • TWO for slave node
No alt text provided for this image

KUBEMASTER-

No alt text provided for this image

SIMILARLY

KUBESLAVE1 AND KUBESLAVE2

No alt text provided for this image

(NOTE:: you can create more slaveS also i am cloning two for testing purpose )

---------------------------------------------------------------------------------------------------------------

NOW LAUNCH VM of KUBEMASTER and set the host name-

  • hostnamectl set-hostname master
No alt text provided for this image

to verify hostname type : hostname in the command line

-->NOW LAUNCH ALL the VM for slave nodes (KUBESLAVE1 and KUBESLAVE2) and set the hostname for them also (same process as above)

------------------------------------------------------

--> NOW to check connectivity from slave to master ping thenm with each other

for example::

from slave1 node run cmds

  • ping masterip
  • ping slave2ip
No alt text provided for this image

(repeat same from masternode and slave 1 node)

----------------------------------------------------

NOw GO TO HOST FILE of master(or you can choose slave also) VM

first of all use putty to go inside all the VM(how to use discussed above)

  • vim /etc/hosts
No alt text provided for this image

-in this file put the host name with their respective ip addresses (repeat same process for other two slaves also or you can copy paste or use scp command to transfer this file t oother VM )

No alt text provided for this image

BYdoing this you can ping them by there names you did't need to remember there ip address

No alt text provided for this image
No alt text provided for this image
No alt text provided for this image

--HERE YOU CAN SEE THEY ARE PINGING BY THERE NAME

No alt text provided for this image

NOW run

  • kubeadm init command to initialize the setup
No alt text provided for this image

--TO set the range of ip addresses for the pods run the following command

No alt text provided for this image

-IF THIS COMMAND RUNS successfully it means you have done all the configurations correctly and at the end this command will provide you the token which you have to copy paste in the node VM to configure and connect them as a slave node

(save this token in a txt editor for future use)

No alt text provided for this image
No alt text provided for this image

NOW THIS IS RUN THESE IMPORTANT COMMANDS TO STOP THE FIREWALL OF each node()

  • systemctl stop firewalld
  • systemctl disable firewalld

NOW run the TOKEN IN EACH SLAVE NODE

No alt text provided for this image

NOW your multi node cluster is all set


-- run the underlined command to see if nodes are ready or not(this can take few minutes)

No alt text provided for this image

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

NOW TO USE THIS K8S cluster first tcopy the configuration from this MASTER'S rhel8 VM to windows base OS or any of your BaseOS present the Network using WINSCP.

No alt text provided for this image

--now open command prompt and run this command to see if all nodes ready or not

No alt text provided for this image
No alt text provided for this image

---NOW LETS TEST THE SYSTEM BY CREATING THE POD

  • WHEN i run the first command it runs succesfully as you can see pode created
  • by typing the last command in the screenshot you can see in which node your POD is CREATING
No alt text provided for this image

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

SETUP COMPLETE:::::::::::::::

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

THANK YOU for reading this article I hope this will definitely help you to test this powerful mini testing setup of Kubernetes on you personal computer

please do like share and comment









要查看或添加评论,请登录

Raghav Tiwari的更多文章

社区洞察

其他会员也浏览了