Hello Everyone, today I am going to explain how to setup a Kubernetes Multi-Node cluster on AWS Using the Ansible tool.
Kubernetes Multi-Node cluster on AWS Using Ansible |
Steps to be followed:
1) First, we are going to launch 2 instances, one is for Master Node and another one is for Worker Node and in this practical, we will configure the client system in the master Node itself to save our time.
2) Then we will create two playbooks for launching two ec2 instances on the AWS cloud with the dynamic inventory.
Master Node Instance |
Worker Node Instance
How to Setup Dynamic Inventory in Ansible
3) Then we will create two different roles for Master Node and Worker Node.
Master Node Role |
Worker Node Role |
How to Configure the Master Node
1) First, we will download the docker software so that we can launch the container on top of the docker and download the iproute-tc software to setup the group's drivers and iptables.
2) Then, start the service of Docker so that further, we can use this software.
3) Now, for configuring the Kubernetes, we have to configure the repository of yum, so for configuring the Kubernetes, we will use the yum_repository module.
Configuration setup of Master Node |
4) Then we will download the kubeadm software, it will help to setup the cluster and it will provide the kubelet and kubectl.
Here, kubelet is an agent program that is present on every Nodes and kubectl is a client program that runs the commands against the cluster.
5) Then we will start the service of kubelet program.
6) Then we will copy the daemon.json file.
Configuration Setup |
Daemon.json |
7) Then we will initiate the process of Multi-Node Cluster by running the command shown below in the image.
8) Then the kubeadm init command gives the further steps to do (further commands help to create the client).
9) Then, to run all the pods, we will run the Kube-flannel.yml file.
Note: Flannel is a CNI Plugin that helps in the networking and it is an overlay network that satisfies the requirement of Kubernetes.
Configuration Setup |
10) After following the above steps, we will create a token so that the Worker Node can join the Master node using this token.
11) We will store the token in the dummy host using the add_host module.
Configuration Setup |
Master Node Instance launched |
How to Configure the Worker Node
1) First, we will download the docker software and iproute-tc software so that we can launch the container on top of the docker
2) Then, start the service of Docker, so that further, we can use this software
3) Now, for configuring the Kubernetes, we have to configure the repository of yum, so for configuring the Kubernetes, we will use the yum_repository module.
Configuration Setup of Worker Node |
4) Then we will download the kubeadm software, it will help to setup the cluster and it will provide the kubelet and kubectl.
5) Then we will start the service of kubelet Program.
6) Then we will copy the daemon.json file.
Configuration Setup |
Worker Node Instance Launched |
Includes both roles |
Here, we used the include_role option, because we want to run the playbook at the task level.
Master Node Setup Done |
Final Output of the Playbook Now, the Complete Setup of a Multi-node cluster of Kubernetes on AWS has been done. |
Github Link: https://github.com/technicalej/Multi-Node-Cluster-of-k8s-on-AWS
Worker Node Role: https://galaxy.ansible.com/technicalej/k8s_setup_of_worker_role
Master Node Role: https://galaxy.ansible.com/technicalej/k8s_setup_of_master_role
No comments:
Post a Comment
If you have any doubts, Please Comment down