Hello readers, in this blog i will be deploying the Wordpress application on Kubernetes locally and using AWS RDS as database for our application by using Terraform.
- AWS CLI software configured with a profile. You can get from here.
- Knowledge of AWS Cloud Computing and Terraform.
- Terraform setup. You can get from here.
- Minikube setup with kubectl. You can install minikube using this guide from here and kubectl from here.
- You can get my code from here.
Steps while performing our project:
- Write an Infrastructure as code using terraform, which automatically deploy the Wordpress application.
- From above code , also deploy RDS service for the relational database for Wordpress application.
- Also create Load Balancer so that our application is accessible from our workstation.
Below are the steps how you can successfully execute my code:
Step 1: Start your minikube machine.
Step 2: Configure your aws profile with below cmd
Step 3: Now below will be steps for code completion. If you are not interested then you may skip to Step 4.
- For providing provider info of kubernetes and aws.
- For creating rds db instance. In this case db instance will be created in default vpc. To get more options and control according to your desire you can refer here.
- For creating k8s resources like secrets, deployments and service for load balancer.
- For getting inputs from user like database name, username and password a variables file was created to take input from user while running code.
That’s it for coding part. Now execution part resumes.
Step 4: Go inside directory where your terraform files are present and run
It will install all the necessary plugins for your code.
Step 5: Now run
Then it will ask to enter the database name, username and password and after that it will validate and prompt to enter yes to deploy whole setup.
Note: Databse creation takes around 5 minutes so be patient.
Step 6: You can verify your k8s infrastructure using
kubectl get all
and AWS RDS database from AWS console.
Step 7: Now enter your minikube ip along with Load Balancer port no. in your browser.
To get minikube ip use below command
and to get port no, you can see from kubectl get all command
Step 8: After entering correct url, you will be able to see WordPress installation page if all went successfully.
Step 9: After Logging in, you will be able to see WordPress Dashboard and you can do anything with it.
Here’s a demo blog published using WordPress
Step 10: For removing all your setup use command
then it will prompt to say yes, enter yes to delete your whole setup in one go. Again it will take some time to destroy your whole setup. So be patient.
Note: You can cross-verify your resources by kubectl get all command also don’t forget to turn off your minikube by command minikube stop.
So that’s it folks for this blog. Hope you liked it. See you in next blog.
Contribute to Apeksh742/Terraform_for_wordpress_on_k8s_with_rds_db development by creating an account on GitHub.