Deployment Of Wordpress On Kubernetes With AWS RDS Using Terraform

Deploy the Wordpress application on Kubernetes and AWS using terraform including the following steps;

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.

Let's get started...

In this task, I have written Infrastructure as code using Terraform, which automatically deploy the Wordpress application. On AWS, I have used RDS service for the relational database for Wordpress application. Then I deployed the Wordpress as a container on top of Minikube, the Wordpress application is accessible to the public world.

Kubernetes is a portable, extensible, open-source platform for managing containerized workloads and services. On K8S (short for Kubernetes) we create containers and launch our application on top of these containers. Containers provide isolation and everything is managed by K8S.

Containers are a good way to bundle and run your applications. In a production environment, you need to manage the containers that run the applications and ensure that there is no downtime. For example, if a container goes down, another container needs to start. This is where Kubernetes helps us. Everything is managed by Kubernetes itself. We just need to specify the templates of the container and Kubernetes will do its job.

Minikube is an open-source tool that helps to run Kubernetes on a local computer. Before using minikube we need to start it so here I wrote terraform code to start minikube on my Local Computer.

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.

Before that, I’m gonna tell you some basics about Terraform we make use of the following the commands

Let’s go by each step to understand the task in the simplest manner

Creating the separate folder for web page code and in that create terraform file with extension .tf and after initializing the terraform file so that it can download the required plugins for that particular folder. We have to log in to AWS CLI

We need to specify the region and profile name for setting up the provider in Terraform. Which logins to the AWS account to perform actions. And Also we need to start our Minikube VM.

Now we need to write the code for deploying Wordpress on Minikube. We will also be creating a Load Balancer service on Kubernetes which will expose our deployment.

wp.tf File

It will launch the Wordpress Application

Now we need to create our Database where the WordPress application will store all its data. For this, we are using AWS-RDS.

db.tf file:-

It will create the RDS on top of AWS.

main.tf File

It will provide the IP to connect to Wordpress.

We will use the minikube IP

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store