Automate Kubernetes Cluster Using Ansible and launching WordPress MySQL

Nischal Vooda
3 min readAug 27, 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

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:32130

This above port can differ as in the above image we can see it is 32130 in highlighted external ip so you can check your port with the same command.

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.

for Any Suggestions or difficulties DM me.

--

--

Responses (1)