MULTI-CLOUD Setup Of Kubernetes MULTI-NODE Cluster

Creating Multi-cloud setup of kubernetes cluster on Aws and Azure cloud.

Kubernetes Cluster

Hello All …. !!

This is Pritee , and I am again come with new and interesting article. By seeing title I think you got it …yes it’s on multi-cloud setup of Kubernetes multi-node cluster.

So let’s start , but before that let’s know more about basic terms that is Kubernetes, AWS , Azure cloud etc.

Kubernetes :

Kubernetes is a portable, extensible, open-source platform for managing containerized workloads and services, that facilitates both declarative configuration and automation. It has a large, rapidly growing ecosystem. … The name Kubernetes originates from Greek, meaning helmsman or pilot. Kubernetes is an open-source container orchestration platform that enables the operation of an elastic web server framework for cloud applications. Kubernetes can support data center outsourcing to public cloud service providers or can be used for web hosting at scale.

Amazon Web Services :

AWS (Amazon Web Services) is a comprehensive, evolving cloud computing platform provided by Amazon that includes a mixture of infrastructure as a service (IaaS), platform as a service (PaaS) and packaged software as a service (SaaS) offerings.Amazon Web Services offers a broad set of global cloud-based products including compute, storage, databases, analytics, networking, mobile, developer tools, management tools, IoT, security and enterprise applications. These services help organizations move faster, lower IT costs, and scale.

Azure :

Microsoft Azure, commonly referred to as Azure, is a cloud computing service created by Microsoft for building, testing, deploying, and managing applications and services through Microsoft-managed data centers. At its core, Azure is a public cloud computing platform — with solutions including Infrastructure as a Service (IaaS), Platform as a Service (PaaS), and Software as a Service (SaaS) that can be used for services such as analytics, virtual computing, storage, networking, and much more.

I hope you understand the basic things about this task now let’s move towards main part.

Pre-requisites :

  1. Account On Azure Cloud
  2. Account On AWS Cloud

For Creating Account On Azure Refer Below link :

For AWS Account refer this :

Now , first I clear you all that I am launching 3 instance in a AWS cloud in that 1 is Master node and other 2 are Slave nodes and 1 virtual Machine on Azure cloud which act as a Slave node.

Now first you have to launch instance on AWS for that I give you some steps which you have to follow ..

First go to AWS portal then EC2 service and after that there is an option for launch instance , click on it..

Then after that we have to select the AMI/Image type , which OS we want to launch ..

After Selecting this go to next step for choosing instance type..

Here I choose t2.micro , we can choose according to your choice. Now go next for configure instance..

Here I am given 3 instances to launch according to our plan. Now , after that go next for add storage..

Here I add 8 GiB we can add as much you want. Next step is giving tag or name to your instances..

After that configure the Security Group ..

Now , here I am giving All traffic security group type and it is for allowing all IP and for avoiding further errors. Now after that review and launch instance.

Now your 3 instance launched .

Here you can see , 3 instance running in that one is master and other 2 are slave nodes.

Now we have to launch 1 slave on Azure also for that also I show you some steps you should follow them..

First go to Azure portal and in that search for Virtual Machine and select Add Virtual Machine option of Azure for launching new OS.

After that give name to your resource group and virtual machine.

Here also select region and Image for launching instance. I am selecting RedHat Linux and here we have to create new user and give them password.

Here I am creating rootadmin user and set password also. with that we have to select an inbound port , I am selecting SSH(22). Now step is configure disk info ..

Here I am giving Premium SSD (LRS). Next step is configure networking setup..

Here I am selecting all by default values. In next step we see Management option set it default and in Advanced setting also don’t change anything.Move towards next part and that is tags..

After all this process , review and then create the virtual machine and resource group.

Here , KubeSlave is my virtual machine name and it’s running in state. In that by default they launch all required things like IP, security group,etc.

Now our all nodes are created , but we have to configure it. So for we do further things.

Now have to do some steps in one instances of AWS for configure the Master. So let’s get started..

Kubernetes is based on docker technology so we have to first configure the docker , so for that use below command ..

yum install docker -y

Now, start and enable the docker service.

systemctl start docker
systemctl enable docker

Now we have change the docker driver from cgroupfs to systems, so for that use below code..

vim /etc/docker/daemon.json
"exec-opts": ["native.cgroupdriver=systemd"]

Now after changing this we have to restart the docker for that use command..

systemctl restart docker

Now , we have configure the Kubernetes but for that we have first configure the repo for installing packages for K8s and that create one file in /etc/yum.repos.d/(file name) folder having .repo extension and in that write below code..


Now we have to install some packages like kubeadm , kubectl , kubelet for configure the nodes ..

kubeadm : Kubeadm is a tool built to provide kubeadm init and kubeadm join as best-practice “fast paths” for creating Kubernetes clusters.

kubectl : You can use kubectl to deploy applications, inspect and manage cluster resources, and view logs

kubelet : The kubelet is the primary “node agent” that runs on each node. It can register the node with the apiserver using one of the hostnames.

Command for installing this packages..

yum install kubeadm kubectl kubelet -y

Now after that start and also enable the kubelet service..

systemctl enable kubelet --now

Now kubeadm is help for pulling the docker images for launching the containers so we have to configure it..

kubeadm config  images pull

After that install the iproute-tc tool , it is for managing the traffic on cluster.

yum install iproute-tc 

Next step is changing the IP tables in a /etc/sysctl.d/k8s.conf file..

vim /etc/sysctl.f/k8s.confnet.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1

Now the next step of configuring master is , initializing the master node and for that we use below command..

kubeadm init --control-plane-endpoint "PUBLICIP:PORT" --pod-network-cidr= --ignore-preflight-errors=NumCPU --ignore-preflight-errors=Mem

Note :

** pod-network-cidr= IP range (for pods inside the slave nodes)

** Control plane endpoint = assign the cluster with a public IP with port

** ignore-preflight-errors= Ignoring the unwanted CPU errors and memory errors

Now the initialized the master using below command ..

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

To connect the nodes of the master and slave we use a flannel. Flannels act as a DHCP server as well as a router in the cluster. It will create a connection between the pods running in the cluster. The flannel works on the underlying network.

For download and configure the flannel use below command..

kubectl apply -f

Now , the final and important step of master configuration is generating tokens and it is for connecting master node with slave node. Then for that use a below command..

kubeadm token  create  --print-join-command

After creating token we will run it on slave for connection..

So our Master is Ready…

Now , let’s start to configure the Slave node in 2 AWS instance and in 1 Azure instance..

For configure slave use below lists of command after one after another. Because this are the same steps which we are done while configuring the master node ..

yum install iproute-tc            #Installing iproute-tcyum install docker -y             #Install Dockervim /etc/docker/daemon.json       #Changing the driver
"exec-opts": ["native.cgroupdriver=systemd"]
systemctl restart docker #Restart docker
systemctl enable docker --now #enable Docker
#Kubernetes Repositoryvim /etc/yum.repos.d/k8s.repo [kubernetes]
#Installing the required packages
yum install kubeadm kubectl kubelet -y
#Enabling kubelet service
systemctl enable kubelet --now
#Configure the iptables /etc/sysctl.d/k8s.confvim /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
sysctl --system

This are the same commands which we used in master and there we see detailed info of each and every command . After running all this command successfully our slave is configured.

Now we have do one extra thing and that is we have run the master created token in a slave node .. now if create a token on master for which I already command gave use this and create token..

Our token is created successfully. Now we have to run it on slave node and after that our nodes connected with each other.

Now after running this token in every slave node our cluster is created and checking the running nodes use below command in master node..

kubectl get nodes

You can see here our all slaves are connected to master node . That means our cluster is created successfully..

So finally our did it ..

I hope this article help you for creating multi-node cluster on multi-cloud. If you like it then clap and share. And you want to connect with me then below is LinkedIn Profile Link..



Get the Medium app