Amazon RDS as Storage of Wordpress and controlled by Kubernetes’s management
Pradeep K.
Strategic Operations Leader | Proactive Negotiator | Team Dynamics Expert | Applying Computer Science for Seamless Client Relationships and Actionable Leadership
Description:
Deploying up of the Wordpress Website on top of kubernetes and storing the data in PVC and attaching it to the Amazon-RDS
What is Kubernetes ?
Kubernetes is an open-source container-orchestration system for automating computer application deployment, scaling, and management. It was originally designed by Google and is now maintained by the Cloud Native Computing Foundation
What is Amazon-RDS ?
Amazon Relational Database Service (Amazon RDS) is a web service that makes it easier to set up, operate, and scale a relational database in the AWS Cloud. It provides cost-efficient, resizable capacity for an industry-standard relational database and manages common database administration tasks.
Which contains like DB services like:
- MariaDB on Amazon RDS
- Microsoft SQL Server on Amazon RDS
- MySQL on Amazon RDS
- Oracle on Amazon RDS
- PostgreSQL on Amazon RDS
We will deploy the WordPress application on top of Kubernetes which will be connected to the AWS-RDS database where it will store all the critical information. We will create this infrastructure using Terraform.
Steps to the task include the following:
- Write an infrastructure as code using terraform which automatically deploy the WordPress application.
- On AWS use RDS service for the relational database for WordPress application.
- Deploy the Wordpress as a container either on top of minikube or EKS or Fargate service on AWS.
- The WordPress application should be accessible from the public world if deployed on AWS or through workstation if deployed on Minikube
And here is the Step wise overall to be followed:
Firstly configure Aws on CLI using new_user
Now write the Code as a Infra-structure using Terraform.
provider "aws" { region = "ap-south-1" profile = "default" } provider "kubernetes" { config_context_cluster = "minikube"
}
We have defined the context and the Profile is already configured
Now we will add the resource called kuberentes_deployment in terraform with the type called Recreate when pod failed to run, and also given it the Labels to identify them in terms of pod recreation or in between two pods.
Added the persistant storage to the deployment of pod
resource "kubernetes_deployment" "MyDeployment" { depends_on = [kubernetes_persistent_volume_claim.PVC] metadata { name = "wordpress-deployment" labels = { type = "frontend_deployment" } } spec { replicas = 1 strategy { type = "Recreate" } selector{ match_labels = { type = "checking" env = "prod" } } template { metadata { labels = { type = "checking" env = "prod" } } spec { container { image = "wordpress" name = "wordpress" port { container_port = 80 } volume_mount { name = "wordpressvolume" mount_path = "/var/www/html" } } volume { name = "wordpressvolume" persistent_volume_claim { claim_name = kubernetes_persistent_volume_claim.PVC.metadata.0.name } } } } }
}
Now as we have seen the load balancer is been added as the type is Recreate we have to use the Load balancer to specify how many pods and when and where they need to be created or to be available
resource "kubernetes_service" "loadbalancer" { depends_on = [kubernetes_deployment.MyDeployment] metadata { name = "wordpress-service" } spec { type = "NodePort" selector = { type = "cms" } port { port = 80 target_port = 80 protocol = "TCP" } }
}
Note: Port 80 is kept open for the web-server access
Major part Comes Creation of RDS
resource "aws_db_instance" "RDS" { allocated_storage = 20 storage_type = "gp2" engine = "mysql" engine_version = "5.7" instance_class = "db.t2.micro" name = "RDS" username = "pradeep" password = "pradeeppass" skip_final_snapshot = true publicly_accessible = true port = 3306
}
Now the Code is done now lets DEPLOY it.
Terraform init
Terraform apply --auto-approve
Now we have the pods deployed and Code applied successfully ????
Finally deployed similar website again...????
Thanks for Reading...and any addition can also be done
Github URL:
https://github.com/KVSSKPRADEEP/HMC_task6.git