Ansible Role to Configure k8s Multi Node Cluster over AWS Cloud.

Created a k8s multinode cluster over AWS cloud, then created an Ansible Playbook to launch 3 AWS EC2 Instance, Ansible Playbook to configure Docker over those instances & created Playbook to configure k8s Master, k8s Worker Nodes on the above created EC2 Instances using kubeadm.


Created a Configuration File.

Configuration file
  • Step 1
  • Step 2
Two executable file in my dynamic inventory folder.
  • Step 3
  • Step 4
Changed in file
Changed in ec2.ini file
  • Step5
  • STEP 6
IP of all the ec2 instance in my ap-south-1 region.
  • STEP7
Checking the connectivity.


Created the role for multiple used cases step by step as following

  • For Launching a VPC, Igw, Subnet, Route table

Tasks file

Task in Tasks file.

Vars file

All variables in Vars file.
  • Provisioning an AWS ec2 Instance in that VPC.

Tasks file

Provisioning AWS ec2 instance

Vars file

Variables used in Tasks file .
  • Configuring Kubernetes master on one of the instance.
Configuring k8s Master.
  • Configuring Kubernetes slave on two of the instance.
Configuring k8s Slave.
  • Launching Wordpress & mysql server on kubernetes slave by using k8s Master node.
Wordpress and mysql server.


Playbook to launch a VPC on AWS and ec2 instance simultaneously.

Playbook for VPC and ec2-instance.
Running Playbook


Playbook to launch kubernetes cluster ie, master-slave model and then launch Wordpress & mysql simultaneously.

Playbook for kuberntes Cluster, WordPress and mysql.
Running the Playbook.
VPC, Subnet, Internet Gateway, Route Table and ec2 instance


Next, I have updated the details WordPress required and then providing MySQL details, It brings to the end of my practical and leads to the great used cases to be solved.

Wordpress server

Open for any Queries and suggestions. Click Here





Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store