Integrating Kubernetes & AWS-RDS using Terraform!

This blog will explain the process of Launching WordPress in Kubernetes POD using Minikube on the local machine, & then connecting it to the Database(MySQL) instance of RDS launched in AWS using Terraform!

Harshit Dawar
2 min readAug 25, 2020
Source: Yang Shuo via Unsplash

Ever wondered of launching fault-tolerant Kubernetes Deployment and integrating it with the cloud, and that too using Terraform. If no, then this blog will guide you to launch a Kubernetes Deployment of WordPress which is Fault-Tolerant using Minikube on the local machine, & also integrating it with AWS RDS for the Database. In addition to that, this whole task will be automated with the use of a very famous & mature provisioning tool “Terraform”.

Link to the complete Terraform code for the same is present at the end of the blog.

Prerequisites for the same practical

  • AWS account
  • Minikube & VirtualBox Installed on the local machine.
  • Terraform installed on the local machine.

Note: Core knowledge of Docker will be very helpful in differnet projects like this, but here it is not as such required.

Practical Implementation

This implementation can be understood in the following 3 steps:

  1. Creating Kubernetes Deployment.
  2. Exposing the Kubernetes Deployment by creating a Kubernetes Service, so that WordPress can be accessed by any machine in the same network.
  3. Creating AWS RDS MySQL Database Instance for WordPress to store the data.

Note: Some variables is used in the code below, the code of which is present at the end of the main code.

Creating Kubernetes Deployment!

Code to create the Kubernetes-Deployment of WordPress using Terraform!

Creating Kubernetes Service to expose the above-created Deployment!

Code to expose the Kubernetes-Deployment of WordPress using Terraform!

Creating AWS RDS MySQL Database Instance!

After combining the whole code above in one file and running it using the command terraform apply, it will create the complete Infrastructure for you.

After the successful run of the code, one url will be printed at the end, put that in the database host in the wordpress setup.

Variable File for the above Code

Link to my GitHub Repo for the complete code:

After the complete WordPress setup, I have published one blog, and it will look like this.

Image by Author!

This is all from my side in this blog, stay tuned for my further amazing blogs!

I hope my article explains each and everything related to the topic with all the deep concepts and explanations. Thank you so much for investing your time in reading my blog & boosting your knowledge!

--

--

Harshit Dawar

AIOPS Engineer, have a demonstrated history of delivering large and complex projects. 14x Globally Certified. Rare & authentic content publisher.