Deployment of Web Application On Local Kubernetes Cluster by Integrating with AWS RDS using Terraform

Deployment of Web Application On Local Kubernetes Cluster by Integrating with AWS RDS using Terraform

𝗛𝗲𝗹𝗹𝗼 Friends !! Welcome you all to my article on Deployment of Web Application On Local Kubernetes Cluster by Integrating with AWS RDS using Terraform. An overview of Kubernetes and AWS Service RDS With Terraform will also be present. Finally How can we utilize Terraform with AWS and Kubernetes for webserver deployment? We are also utilizing or building Terraform to create this application, as well as Deployment of Web Application on Kubernetes. Deployment of Web Application On Local Kubernetes Cluster by Integrating with AWS RDS using Terraform.

DESCRIPTION OF THE TASK:

  • πŸ”· Using Terraform, create an Infrastructure as Code that deploys the WordPress application automatically.
  • Use RDS for the relational database for the WordPress application on AWS.
  • Install WordPress as a container on top of Minikube, EKS, or the AWS Fargate service.
  • If implemented on AWS, the WordPress application should be available via the public internet; if put on Minikube, it should be accessible through a workstation.
  • ⏩ In this work, we’ll use terraform code to automate the deployment of a Web application utilizing Infrastructure As A Code, integrating the local kubernetes cluster with AWS RDS.

COMPLETION OF THE TASK:

1) We need to develop Infrastructure As Code (IaC) using Terraform to deploy WordPress applications to a Kubernetes cluster automatically. In my situation, I use Minikube to run a local Kubernetes cluster as a workstation.

So, let’s get start writing Infrastructure As Code with Terraform for WordPress application deployment on Minikube Kubernetes Cluster.

Deployment of Web Application On Local Kubernetes Cluster by Integrating with AWS RDS using Terraform
Kubectl command

Finally The Replica Set field in the above terraform code defines a selector that indicates how to identify Pods it can acquire, a number of replicas indicating how many Pods it should maintain, and a pod template providing the data of new Pods it should produce to fulfil the number of replicas criterion. The objective of a ReplicaSet is then fulfill by producing and removing Pods as necessary to meet the specified number. The Pod template is use by a ReplicaSet to construct new Pods.

To acquire the facility of a Load Balancer and to expose the deployment of a Web Application to public global access, use the Kubernetes service. Here, I’m using the Kubernetes service Node Port, which acts as a load balancer but isn’t an external load balancer like AWS’ Elastic Load Balancer. We can also utilise ELB to provide these services.

2) Next, we must execute the Terraform code.

Before we can run the code, we must first initialise it and download the appropriate Terraform for Kubernetes plugins.

terraform init 
Kubernetes

Before running our code, it’s usually a good idea to understand the basic procedure. Because we need to inspect the terraform code plan initially, we’ll use the command β€”>

terraform plan
Kubernetes
Deployment of Web Application On Local Kubernetes Cluster by Integrating with AWS RDS using Terraform
Kubernetes kubectl command

Deployment of Web Application On Local Kubernetes Cluster by Integrating with AWS RDS using Terraform

Kubernetes

Following the terraform plan, we now run the terraform code, which creates Infrastructure As A Code with the command β€”>

terraform apply
Deployment of Web Application On Local Kubernetes Cluster by Integrating with AWS RDS using Terraform

3) Now we can also see that the WordPress application has been deployed to a local Kubernetes cluster call Minikube.

Using the command –>

kubectl get all
Kubectl

you can check if everything in your Kubernetes cluster is correctly deployed or not.

4) We also used Terraform to successfully install a WordPress application on Kubernetes.

Now we also must construct a database-driven back end for WordPress. It is also always vital to maintain the database of any online application, which is why we utilize AWS Cloud’s Relational Database Service as a Database As A Service (RDS).

We also use Amazon Web Services’ MySQL RDS for WordPress. Now we also must write more Terraform code for MySQL RDS, which will establish a single MySQL database using RDS.

MySQL RDS Terraform code β€”>

Terraform

terraform

5) For the RDS terraform code, we must once again initialise, plan, and apply the terraform code.

We can see in AWS GUI Console one MySQL database is created in RDS –>

terraform init
Deployment of Web Application On Local Kubernetes Cluster by Integrating with AWS RDS using Terraform
terraform planterraform apply
Deployment of Web Application On Local Kubernetes Cluster by Integrating with AWS RDS using Terraform

Deployment of Web Application On Local Kubernetes Cluster by Integrating with AWS RDS using Terraform
terraform apply
Kubernetes

We can see in AWS GUI Console one MySQL database is create in RDS –>

AWS RDS

AWS RDS

AWS DataBase

6) Finally, we can use the service URL supplied by the Kubernetes cluster’s Node Port to run the WordPress application.

Use the command to view the minikube service URL –>

minikube service list
Deployment of Web Application On Local Kubernetes Cluster by Integrating with AWS RDS using Terraform

WordPress

Enter the relevant details of the database we use for the back end as shown below to link MySQL database established by RDS to WordPress Application β€”>

Deployment of Web Application On Local Kubernetes Cluster by Integrating with AWS RDS using Terraform

WordPress

Deployment of Web Application On Local Kubernetes Cluster by Integrating with AWS RDS using Terraform

Related Articles: Deployment of Web Application On Local Kubernetes Cluster by Integrating with AWS RDS using Terraform

Deployment of Web Application On Local Kubernetes Cluster by Integrating with AWS RDS using Terraform

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top