Multi-cloud Multi-node Kubernetes cluster.

Jaindivya
7 min readJul 14, 2021

Task description

CREATE A MULTI-CLOUD SETUP of K8S cluster:

πŸ”… Launch node in AWS
πŸ”… Launch node in Azure
πŸ”… Launch node in Local machine
πŸ”… And one over the network on local system /Cloud -> Master Node
πŸ”… Then set up a multi-node Kubernetes cluster.

Multi-cloud Kubernetes is the deployment of Kubernetes over multiple cloud services and providers.

Most enterprises are already using a multi-cloud strategy. By combining cloud services, organizations can choose the best services for them at the lowest cost.

To do this practical their are some pre-requisites:-

  1. You should have an Account On Azure and AWS Cloud

Let us start with the Practical

Step-1:Launch Ec2 instance

Login to AWS portal β†’ Go to ec2 service β†’ Click on the option called Launch Instances

Select an image.

You can select either AMI or Redhat Image

I selected the instance type as t2.micro

I launched 3 instances

One for Master and two for slave

We can add the storage as 10GiB

Add the security Group

Finally, Your instances is launched

Step2:- Configure Kubernetes master node.

>>Install docker as Kubernetes is based on Docker

>>Start the Docker services

>>Enable the docker service

>>Configure the Cgroup as follows:

>>After configuring restart Docker

You can refer to this link to set up Kubernetes repo:

https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-kubeadm/

>>yum repolist to see if yum is configured.

>>yes Kubernetes is providing us all the software..now you install kubeadm

β€” β€” yum install kubeadm -y β€” disableexcludes=kubernetes β€” -

Your Kubeadm will be installed succefully and along with that,Its dependencies like kubelet and Kubectl is also installed

You can check if kubelet is installed or not by using

rpm -q kubelet

>>Check the docker images you have now

>>kubeadm config images pull will download all the command we need to downoad for master node

>>Now check the docker image, You will find all the necessary images are downloaded for kubernetes cluster

>>Next step is we have to launch a container

>>Kube init means we are initialisting the cluster. This command will setup the master

>>Now pick the error and try to resolve it.

>>While launching who decides what Ip address pod will get?

β€” Master.

For this tc warning, we have to install one software as follows:

>>Now use yum install iproute-tc to install aa software

>>Initalize the pod and ignore the errors

commands:-

mkdir -p $HOME/.kube

sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config

# sudo chown $(id -u):$(id -g) $HOME/.kube/config

>>Check docker ps

>>To connect the nodes of the master and slave we use a flannel

Command:-

kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml

>>Check the kubeadm token list

>>create a kubeadm token in master so the slave node can join

you have to configure slave node exactly as you configured ,master node

In the slave node copy-paste the join command and run as follows:

Slave1 of AWS is connected to our master

Slave node in Azure

>>Create a virtual Machine

>>Create a virtual Machine

Choose the authentication type as password and give the required user-name and Password

>>Select the disk

>>add the inbound rule and outbound rule and allow all the ports

Now you can follow the same steps in Azure :

1) yum install docker -y
2) systemctl enable docker β€” now

β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€”
3) Creating a kubernetes repo
vi /etc/yum.repos.d/kubernetes.repo
β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€”
Write this in above file

[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-\$basearch
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
exclude=kubelet kubeadm kubectl
β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€”
4) Now you can install kubadm , kubelet and kubectl

yum install -y kubelet kubeadm kubectl β€” disableexcludes=kubernetes
β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€”
5) systemctl enable kubelet β€” now
β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€”
6) kubeadm config images pull

7)cd /etc/docker

8)create a file as vim daemon.json

9)write this inside the file:

{
"exec-opts": ["native.cgroupdriver=systemd"]
}

10)Restart the docker services

systemctl restart docker

11)yum install iproute-tc

12)Run this command to set the ridge-nf-call-iptables=1
echo β€œ1” > /proc/sys/net/bridge/bridge-nf-call-iptables

13)Run the cretaed token in slave node

Key point: In Azure Podman is already Pre-installed so remove Podman and install docker

Podman remove command: yum remove podman

I have given the hostname of Azure as slave2

>>get the nodes in master and you will see slave1 and slave2 is joined with master and a cluster is formed

Voila!! We achieved our target!

Sign up to discover human stories that deepen your understanding of the world.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

No responses yet

Write a response