DEPLOYING WORDPRESS USING AWS RDS AND KUBERNETES

Nikhilgubbi
5 min readAug 30, 2020

--

This article is all about how to deploy WordPress website on Kubernetes using database of AWS RDS.

Let’s start with the process of deployment. Here I am assuming you have set k8s in your system. I am using Kubernetes on minikube. One can use aws eks also as discussed in the previous article.

First, let’s start with deploying the WordPress on Kubernetes using terraform. Here I am using a minikube cluster.

Step1: start minikube cluster

After this is done, I have written terraform code for running the local command in our windows command prompt using null resource. One can grab the code from git hub repo that I have attached in the last. Fetch the code from that and move in the directory and after this first command, one have to run terraform init(to install all the required resource). After this one have to run terraform plan to see what’s going to deploy and at last terraform apply which will deploy all the things.

Once this is completed, we need to run two more commands .One minkube IP(to get minkube IP) and kubectl get svc to get ports where our service is deployed.

Once its done go the respective IP and one can see the below type of screen.

Once its complete till here we are good to set a database since we need database name, username, password, and host etc.

I have used terraform for deploying rds. Terraform code can be found on my GitHub repo that one can find at the end of the article. Clone the git repo and open the folder and go to cmnd prompt run all the three commands that we have discussed above while setting WordPress on Kubernetes.

This gonna take some time for deploying rds on aws. In terraform code one thing we have to remember is the line thats has been highlighted in the below pic.

They contain DB username, name, port, and password so set it accordingly. Once deployment is done go to aws console.

In the above image one can see information. Creating means it is been doing some internal job for creating it. Once it is done one can see the domain name in the endpoint. It will be our host.

Once this is created, now we have to create one ec2 instance from which we can see database and table in DB.

Please see the above image carefully. In that I have used some command of MySQL to connect remotely from an instance.

Once databases has been created inside DB then move to WordPress site and fill the required information.

In the above image we can see that the site has been deployed.

Now if one want to destroy it use terraform destroy.

One can find the terraform code here.

--

--