Deploying Wordpress application on Kubernetes with AWS RDS using Terraform
Task : We have to do the following activities step by step!
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 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.
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, PostgreSQL, MySQL, MariaDB, Oracle Database, and SQL Server. You can use the AWS Database Migration Service to easily migrate or replicate your existing databases to Amazon RDS.
LET'S START
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.
This terraform code will deploy our wordprss application in minikube . And for that we will start our minikube using "minikube start" command. Now, we will run the above file using terraform, and the commands for the same is terraform init, terraform plan, terraform apply.
We can check if the pods is running by "kubectl get pods" and "kubectl get all -o wide" commands.
The conatiner is exposed to port 30000 so if any user from outside world want to access the website the user can use minikube ip:30000 to access the website . Now we will deploy the RDS database for our wordpress application in AWS.
Here is our database configuration including username,passwd,cloudwatch logs ,access, and many more. Now we need to initialise it.
Now, we will use the "terraform validate" and "terraform apply" command.
Now, we can check manually database is launched or not.
Finally we can connect our wordpress application to our RDS database .