Deploying WordPress on Kubernetes With AWS RDS using Terraform

Snehalhingane
4 min readOct 18, 2020
AWS_RDS

AWS_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 supports an array of database engines to store and organize data and helps with database management tasks, such as migration, backup, recovery and patching.

Kubernetes and Minikube:

kubernetes:-

Kubernetes is a portable, extensible, open-source platform for managing containerized workloads and services, that facilitates both declarative configuration and automation. It has a large, rapidly growing ecosystem. Kubernetes services, support, and tools are widely available.

minikube:-

Minikube is a tool that makes it easy to run Kubernetes locally. Minikube runs a single-node Kubernetes cluster inside a Virtual Machine (VM) on your laptop for users looking to try out Kubernetes or develop with it day-to-day.

Task(a)

Deploy the WordPress application on Kubernetes and AWS using Terraform including the following steps;

1. Writing an Infrastructure as code using Terraform, which automatically deploy the WordPress application

2. On AWS, using RDS service for the relational database for WordPress application.

3. Deploying 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.

Task(b)

Deploy the WordPress application on Kubernetes and AWS using Terraform including the following steps;

1. Writing an Infrastructure as code using Terraform, which automatically deploy the WordPress application

2. On AWS, using RDS service for the relational database for WordPress application.

3. Deploying 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.

Pre-requisites:

  1. install oracle Virtualbox
  2. install minikube
  3. install terraform
  4. install AWS CLI

Note: Go through my previous blogs for installing above tools

Steps:

minikube start —

Once minikube has started, write the Terraform code which will deploy the WordPress on the Minikube and Mysql on AWS RDS for Database.

Step 1:

Kubernetes deployment with 2 replicas is created. Deployment in Kubernentes uses labels as a selector for determining it’s target pod. Thus we have to provide labels to our pods.

NordPort service of Kubernetes which expose the pods to the port 80 to the public, so that whenever any client comes to the IP of node on the NodePort specified, they will be redirected to the port 80 of WordPress.

Step 2:

Create a security group for the RDS service exposing 3306 port.

Step 3:

For creating AWS services first we have to tell the provider and profile for our AWS. Then use aws_db_instance resource of Terraform which will create a RDS which is publicly accessible so that it can be assessed by the WordPress server running in the Kubernetes.

After writing the code we can get the entire infrastructure by using terraform init command, which first initialize all the plugins required then using terraform apply command, it builds entire infrastructure.

$terraform init —

$terraform auto-apply —

Step 4:

Using kubectl get all command we can see the the resources we have created in the Kubernetes.

$kubectl get all

Step 5:

Everything thing is ready. Now using the minikube IP we can access the WordPress site can configure it.

Yuppp!!! finally your wordpress portal comes up.Now you can do anything from your wordpress site.

Thanks for Reading!!!!

#Linuxword_informatic_pvt_ltd #Vimal_Daga #kubernetes #wordpress #RDS #terraform

--

--