1 min read

How to Setup Multi-Nodes in k8s using Virtual Box in Redhat 8 or Centos

What is Kubernetes?

Kubernetes is an open-source container-orchestration system for automating computer application deployment, scaling, and management. It was originally designed by Google and is now maintained by the Cloud Native Computing Foundation.

Why Multi-Nodes

Why Multi-Nodes? Because it is much faster and available than Single Node for Production to end-user, that's why we are going to setup multi-nodes.

Requirements

Before that, you must start to download minikube for k8s and Vmbox and Redhat image, setup add and install RedHat or Centos OS to vmbox named Main. Let's start open vmbox and start the Main OS.

Setup

Let's install net-tools for IP address and vim for editor CLI
1yum install net-tools vim iproute-tc -y

Docker Required

Kubernetes require in docker package so create file named docker.repo in 3 Nodes and start edit

1vim /etc/yum.repos.d/docker.repo

Make sure edit it below for download and install docker file to your pc

1[docker]
2baseurl=https://download.docker.com/linux/centos/7/x86_64/stable/
3gpgcheck=0

To install docker ce for free and enable and start always running in docker

1yum install docker-ce -y --nobest
2sytemctl start docker
3sytemctl enable docker

Installation K8s

lets install k8s

1cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
2[kubernetes]
3name=Kubernetes
4baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-\$basearch
5enabled=1
6gpgcheck=1
7repo_gpgcheck=1
8gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
9exclude=kubelet kubeadm kubectl
10EOF
11
12# Set SELinux in permissive mode (effectively disabling it)
13sudo setenforce 0
14sudo sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config
15
16sudo yum install -y kubelet kubeadm kubectl --disableexcludes=kubernetes

Setup Multi-Nodes

Make Sure Clone Main to add more two nodes named node1 and node2 in vmbox and must regenerate different networks in different images. we need to add a name in host instead of IP address

Main in vm

1hostnamectl set-hostname main
2exec bash

node1 in vm

1hostnamectl set-hostname node1
2exec bash

node2 in vm

1hostnamectl set-hostname node2
2exec bash

set up Local DNS Name server

1vim /etc/hosts

edit in hosts like this

1192.168.43.35 main
2192.168.43.151 node1
3192.168.43.156 node2

same thing in node1 and node2 VM's

It is easier to transfer to another machine node1 in VM's

1scp /etc/hosts 192.168.43.151:/etc/hosts

node2 in VM's

1scp /etc/hosts 192.168.43.156:/etc/hosts

Now, Create kubeadm ( main )

1kubeadm init --pod-networks=10.10.1.0/16

add config in main os

1mkdir -p $HOME/.kube
2sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
3sudo chown $(id -u):$(id -g) $HOME/.kube/config

now join node1 and node2 to main

1kubeadm join 192.168.43.35:6443 --token 1z41ua.pd2l2pl5df286hcb --discovery-token-ca-cert-hash sha256:4547a1aacde3bd0b1ff37fe27619aa858081634717b212e609dfeba96e0402be

This is done 😀😀

You can enjoy to play container image in 3 nodes

Related Posts

1 min read

Git, Jenkins, Docker Tutorial

1 min read

How to Setup Multi-Nodes in k8s using Virtual Box in Redhat 8 or Centos

4 min read

Globally Style the Gatsby Default Starter with styled-components v5


All Rights Reserved © 2021