Deploying WordPress application on Kubernetes with AWS RDS using terraform
Srishti Jain
DevOps Engineer || Azure 1x || CI/CD || AKS || Jenkins || Kubernetes || Git
>>>>The Objective of the task was to<<<<< 1. Write an Infrastructure as code using terraform, which automatically deploy the Wordpress application 2. On AWS, use RDS service for the relational database for Wordpress application. 3. Deploy the Wordpress as a container either on top of Minikube or EKS or Fargate service on AWS 4. The Wordpress application should be accessible from the public world if deployed on AWS or through workstation if deployed on Minikube.
Amazon Relational Database Service (RDS)
Amazon Relational Database Service (Amazon RDS) makes it easy to set up, operate, and scale a relational database in the cloud. It provides cost-efficient and resizable capacity while automating time-consuming administration tasks such as hardware provisioning, database setup, patching and backups. It frees you to focus on your applications so you can give them the fast performance, high availability, security, and compatibility they need. Amazon RDS is available on several database instance types - optimized for memory, performance, or I/O - and provides you with six familiar database engines to choose from, including Amazon Aurora, MySQL, Oracle Database, etc..
Now's Let jump towards the practical
The easiest way to configure the provider is by creating/generating a config in a default location (~/.kube/config). That allows you to leave the provider block completely empty.
The above file will deploy the WordPress application.
and now we will run the above file using terraform, the commands for the same is
terraform init, terraform plan, terraform apply
We can see that terraform file is executed properly without any error now will check if the pods are running by kubectl get pods and kubectl get all -o wide commands
We can see that the container is running properly and exposed to port 30000 so if any user from the outside world wants to access the website he can use my minikube ip:30000 to access the website. Now we will deploy the RDS database for our WordPress application in AWS and collect all the information like database name password and username to login to WordPress.
The above terraform code for RDS will create RDS in AWS I have provided the database name username and password which we will need while login to WordPress.
Now we will run the RDS file by using terraform
As we can see our terraform code has been executed successfully so now we will go to AWS and check our Amazon RDS database.
Connecting RDS to Word Press
finally, we can connect the WordPress application to our RDS database by providing the username, password, database name, and database host. Now go to google chrome and type the minikube ip:30000 to launch the WordPress application.
We can see that WordPress is connected with our RDS database in AWS and our website is working fine.
Thank you for reading !!!!!!
Senior Cloud & DevOps Engineer at Presidio || IMSEC || 2x AWS Certified || 1x Azure Certified || 1x Terraform Certified || 5?? Gold Level @ HackerRank
4 年Excellent Work ??
Diameter Core & OCS/BSS Specialist (OCS, DRA, PCRF & AAA) || 3xOCI || Oracle Cloud Architect Professional certified
4 年Very detailed Article Srishti
DevOps Engineer | Streamlining Software Development & Deployment Processes | Cloud Computing | Automation | CI/CD | Infrastructure Management | Continuous Improvement
4 年Keep it up
Software Developer | Full-Stack | .Net Core | Angular | Azure | SQL | Agile | 2x Azure Certified
4 年Good work ??