Deploy WordPress Application on Kubernetes and DataBase on RDS services of AWS using Terraform

Deploy WordPress Application on Kubernetes and DataBase on RDS services of AWS using Terraform

Problem Statement :

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 WordPress as a container either on top of Minikube.

4. The WordPress application should be accessible from the public world.


RDS-

Amazon RDS is a service which provides database connectivity through the Internet. RDS makes it very simple and easy to set-up a relational database in the cloud.

Instead of concentrating on database features, you can concentrate more on the application to provide high availability, security, and compatibility. RDS is a fully managed RDBMS service.

Kubernetes-

Kubernetes is a portable, extensible, open-source platform for managing containerized workloads and services, that facilitates both declarative configuration and automation.

It allows you to run multiple Virtual Machines (VMs) on a single physical server's CPU. Virtualization allows applications to be isolated between VMs and provides a level of security as the information of one application cannot be freely accessed by another application.

Virtualization allows better utilization of resources in a physical server and allows better scalability because an application can be added or updated easily, reduces hardware costs, and much more. With virtualization you can present a set of physical resources as a cluster of disposable virtual machines.

Each VM is a full machine running all the components, including its own operating system, on top of the virtualized hardware.

Terraform - 

Terraform is a tool for building, changing, and versioning infrastructure safely and efficiently. Terraform can manage existing and popular service providers as well as custom in-house solutions.

Configuration files describe to Terraform the components needed to run a single application or your entire datacenter. Terraform generates an execution plan describing what it will do to reach the desired state, and then executes it to build the described infrastructure. As the configuration changes, Terraform is able to determine what changed and create incremental execution plans which can be applied.

The infrastructure Terraform can manage includes low-level components such as compute instances, storage, and networking, as well as high-level components such as DNS entries, SaaS features, etc.

Prerequisites:

  1. Account on AWS 
  2. AWS CLI should be installed 
  3. Create aim user and profile must me configured in terminal.
  4. kubectl (client program for kubernetes cluster)
  5. Terraform should be installed in our system
  6. minikube should me installed.

Let's begin-

Step 1

Create a .tf file and write code for Service Provider name, profile name and Security Group for RDS.

No alt text provided for this image

Step 2

Create DataBase Instance to store Data of Webpage.

No alt text provided for this image

Step 3

Kubernetes service provider, create name space for k8 and Create PVC.

No alt text provided for this image

Step 4

Deploy WordPress.

No alt text provided for this image


No alt text provided for this image

Step 5

Now Expose Pod For Public World So that everyone in the world can access our websit.

No alt text provided for this image

Now Save the file and run this command ( terraform init ) this command will download all plugins of your code.

The run ( terraform apply ) this command will apply the code.

After some time your infrastructure will be created.

No alt text provided for this image

Now to know url run this command in ur terminal ( minikube service list ). This command will give you url to setup your wordpress. In my case url is https://192.168.99.101:32123 Now copy this url and paste it into any browser.

No alt text provided for this image

You will get wordpress setup screen. Chose your language and click next.

No alt text provided for this image

Now here fill your details.

No alt text provided for this image

Now Login

No alt text provided for this image
No alt text provided for this image

You can also check DataBase from AWS GUI.

No alt text provided for this image

Now to destroy whole infrastructure in one command just use this command and hit enter.

( terraform destroy -auto-approve ) In some time whole infrastructure will be destroyed.

No alt text provided for this image

Thanks For reading this article Hope my article helped you a loat.

Give Your Feedback please.



要查看或添加评论,请登录

社区洞察

其他会员也浏览了