Vrukshali Torawane / Writings / Create a Multi-Cloud Setup of Kubernetes cluster

Create a Multi-Cloud Setup of Kubernetes cluster

architecture

Description:

CREATE A MULTI-CLOUD SETUP of K8S cluster :

  • Launch node in AWS
  • Launch node in Azure
  • Launch node in GCP
  • One node on the cloud should be Master Node
  • Then set up multi-node Kubernetes cluster.

So to do this task, I have created three nodes :

Master node on AWS, Slave nodes on AWS, Azure, and GCP.

First: Setting up Kubernetes master on AWS :

k8s-1

Step-1: For installing kubelet, kubeadm, kubectl first, we need to set up a repo for this :

Terminal window
vim /etc/yum.repos.d/k8s.repo
# content inside repo k8s.repo
[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

Step-2: Installing required software :

Terminal window
yum install docker kubelet kubeadm kubectl iproute-tc -y

Step-3: Starting and enabling services :

Terminal window
systemctl enable --now docker
systemctl enable --now kubelet

Step-4: We also need to pull docker images using kubeadm. It pulls images of the config files.

Terminal window
kubeadm config images pull

Step-5: Now, we need to change the docker cgroup driver into systemd

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

Step-6: Since we have made changes in docker, we need to restart the docker service :

Terminal window
systemctl restart docker

Step-7: Setting up a network bridge to 1 :

Terminal window
echo "1" > /proc/sys/net/bridge/bridge-nf-call-iptable

Step-8: The important step is while initializing Master, while running preflight the main thing is we need to associate the token to the public IP of instance, so that any of the other nodes can easily connect, so for this use :

Terminal window
--control-plane-endpoint=<PUBLIC_IP>:6443
kubeadm init --pod-network-cidr=10.244.0.0/16 --control-plane-endpoint=<public_ip>:6443 --ignore-preflight-errors=NumCPU --ignore-preflight-errors=Mem

Step-9: Now, make a directory for Kube config files and give permission to them :

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

Step-10: Apply flannel :

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

Step-11: Final step: Generate token so that slave nodes could connect to master node :

Terminal window
kubeadm token create --print-join-command

Second: Setting up Kubernetes nodes on AWS, Azure, GCP :

(Note: Follow same steps in all the three platforms)

  • AWS aws

  • Azure azure

  • GCP gcp

Step-1: For installing kubelet, kubeadm, kubectl first, we need to set up a repo for this :

Terminal window
vim /etc/yum.repos.d/k8s.repo
# content inside repo k8s.repo
[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

Step-2: Installing required software :

Terminal window
yum install docker kubelet kubeadm kubectl iproute-tc -y

Step-3: Starting and enabling services :

Terminal window
systemctl enable --now docker
systemctl enable --now kubelet

Step-4: We also need to pull docker images using kubeadm. It pulls images of the config files :

Terminal window
kubeadm config images pull

Step-5: Now, we need to change the docker cgroupdriver into systemd :

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

Step-6: Since we have made changes in docker, we need to restart the docker service :

Terminal window
systemctl restart docker

Step-7: Setting up a network bridge to 1 :

Terminal window
echo "1" > /proc/sys/net/bridge/bridge-nf-call-iptable

Step-8: Copy-paste the token generated in the master node….

Finally, in the master node :

Terminal window
kubectl get nodes

You will see that all the nodes are connected and are ready : res

...

...