Configuring K8s Cluster using Ansible role in AWS

Ansible

Setup Dynamic Inventory

  1. Create a directory, let us mydb. Using mkdir /mydb
  2. Download the ec2.py and ec2.ini file using: wget <URL> https://github.com/ansible/ansible/tree/stable-2.9/contrib/inventory
  3. Install boto library : pip3 install boto
  4. Change the interpreter written in the first line in the ec.py file.
  5. Now make the files executable using: chmod +x filename
  6. ec2.py will therefore act as the dynamic inventory for you.
EC2.PY FILE AFTER CHANGING INTERPRETER

Set the configuration file

ANSIBLE CONFIGURATION FILE

Create roles

How to create roles?

ROLE IS SUCCESSFULLY CREATED
SIMILARLY, CREATE OTHER TWO ROLES

Role 1: Launches ec2-instances

INSIDE THE ROLE
INSIDE THE TASK /MAIN .YML FILE
INSIDE THE VARS MAIN FILE

Role 2: Configures the instance as K8Smaster

PART 1
PART 2
PART 3

Role3: Configure the instance as WorkerNode

PART 1
PART 2

Create the Main setup file :

ANSIBLE CONFIGURATION

Create the Main file:

MAINSETUP.YML FILE

Run the main playbook:

Output:

SUCCESSFULLY RUN

Thankyou for the read !!

Source Code :

--

--

--

Are you reading ? Cause I am writing :)

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Tableau Pricing — A User Friendly Explanation of Tableau Products

Using streaming to render high-fidelity graphics in AR

Challenge accepted: documenting software

Top 5 Backend Frameworks 2021

Got “Git or Github”?

Steps to Become an Android App Developer

7 Quotes by Albert Einstein That Will Change How You Think Now

Wavefront as a code using Terraform Integration. Part II

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
Divyanshu Sharma

Divyanshu Sharma

Are you reading ? Cause I am writing :)

More from Medium

Which web server is better for you: Apache or Nginx?Which

Cloud Build with Docker and Dockerfile using dynamic environment variables

Part 1: JWE with Spring Security

File parameter in Jenkins Pipeline (creating file from input)