Task: Ansible Role to Configure K8S Multi Node Cluster over AWS Cloud.

Task Description:
đź”… Create Ansible Playbook to launch 3 AWS EC2 Instance
đź”… Create Ansible Playbook to configure Docker over those instances.
đź”… Create Playbook to configure K8S Master, K8S Worker Nodes on the above created EC2 Instances using kubeadm.
For the above steps to be completed, we must know a lot of things and follow few pre-requirements
Pre-Requirements:
a. AWS Account
b. Ansible installed as Controller Node
c. Internet Connectivity
Step1: Here I have Created two roles named as follows:
(a)aws_provision (b) clustersetup
ansible-galaxy init aws_provision
ansible-galaxy init clustersetup
Now we have to do the following steps on the Ansible:
FOR MASTER AND SLAVE BOTH:
♦Configure yum for kubernetes
♦Installing docker
♦Install kubeadm, kubelet, kubectl
♦Start kubelet service
♦Pull the images
♦Edit Daemon.json
♦Restart the docker service
♦Install Iproute-tc
♦kube init
FOR SLAVE:
♦Configure iproutetc
♦Token Join command
Let’s get’s started
STEP2: Provisioning AWS with dynamic inventory.

Vars file also contains something for us:

STEP3:Now running the playbook for launching aws

Finally the AWS EC2 Instances are Launched

STEP4: Now Editing the Task file of cluster_setup role:



STEP5: Now We need to create few file which will be required for the role:

STEP6: Finally running the Role:



STEP7:Now we would check the configuration by logging into the Master node and running: kubectl get nodes
