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.
-->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)
-provide atleast 2 gb ram
--CREATE virtual hard disk
--HD type VDI
DYNAMIC allocation
GIVING size of HD accordingly
CLICK ON CREATE
--------------------------------------------------------------------------------------------------------------
--NOW right click on three horizontal lines and go to settings
--ARRANGE boot order like this
--ATTACH iso file of RHEL8 (which u can get for free from REDHAT official site)
--ATTACH bridge network card (for both NAT and host connectivity)
--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
-DISABLE kdump for so that unwanted ram will not be used
-MAKE Ethernet ON so that networking start just after VM launch
-CLICK on Minimal installation for CLI launch
---------------------------------------------------------------------------------------------------------------
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:
--AFTER configuring yum run commands
-yum install net-tools vim to intall some basic commands
- ifconfig to see your ip address
----------------------------------------------------
2)docker configuration(for containerization )
run cmds-
- vi /etc/yum.repos.d/docker.repo
-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
-->accessing VM os via putty
-open putty
-add ip address of your VM-
-and click on open and provide root login id and password:
---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)
-after pasting the commands we get :
NOW run this command to download commands and other important files for kubernetes:
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
- make selinux permissive
---------------------------------------------------------------------------------------------------------------
:::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
--now run the command to disable swap in fstab
- vim /etc/fstab
---LAST and final step set iptables so ip can be seen on bridge
copypaste these commands:
first run
- yum install iproute-tc
then
NOW we have t ostart and enable kubelet
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
KUBEMASTER-
SIMILARLY
KUBESLAVE1 AND KUBESLAVE2
(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
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
(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
-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 )
BYdoing this you can ping them by there names you did't need to remember there ip address
--HERE YOU CAN SEE THEY ARE PINGING BY THERE NAME
NOW run
- kubeadm init command to initialize the setup
--TO set the range of ip addresses for the pods run the following command
-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)
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
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)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
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.
--now open command prompt and run this command to see if all nodes ready or not
---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
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
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