Automate Kubernetes Cluster Using Ansible

Manojnagabairu
3 min readSep 7, 2022

Task Description:-

📌 Automate Kubernetes Cluster Using Ansible

🔅 Launch ec2-instances on AWS Cloud eg. for master and slave.

🔅 Create roles that will configure the master node and slave node separately.

🔅 Launch a WordPress and MySQL database connected to it in the respective slaves.

🔅 Expose the WordPress pod and the client is able to hit the WordPress IP with its respective port.

So let’s begin with the launching of the ec2 instance

For a detailed setup of K8s Master and Slave visit the below link in which I told about the launching of Master and Slave using Ansible.

Step 1:- Launching ec2 instance using Ansible

Step 2:- Let’s launch the K8s master and Slave using Ansible

now lets launch slave

Step 3:- Let’s launch the WordPress and SQL database

let’s run the file

Step 4:- let’s connect to our WordPress account

Publicip of slave :port no

In my case it is

ip of slave:31787

Let’s configure the things here we need to provide the database Host it is the IP of the database pod.

we get IP while running the playbook for installation of WordPress and MySQL database.

from here but in my case it is in creating state only so i login to the master and taken the IP from it using Kubernetes command

kubectl get pods -o wide

here we get the IP for the database so that it copy-paste the IP and that it.

provide the details

and that its. done!!

Hope you like it.

--

--