DEPLOY WORDPRESS ON KUBERNETES AND INTEGRATING IT WITH AWS RDS
TASK 6:
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.
BEFORE MOVING TOWARD THE SOLUTION LET UNDERSTAND FEW TERMS:
Wordpress:
WordPress is web publishing software you can use to create your own website or blog. Since it was released in 2003, WordPress has become one of the most popular web publishing platforms. And today it powers more 35% of the entire web — everything from hobby blogs to some of the most popular websites online.
WordPress enables you to build and manage your own full-featured website using just your web browser—without having to learn how to code. In fact, if you’ve ever used a text editor like Microsoft Word, you’ll be right at home with the WordPress Editor. WordPress is web publishing software you can use to create your own website or blog. Since it was released in 2003, WordPress has become one of the most popular web publishing platforms. And today it powers more 35% of the entire web — everything from hobby blogs to some of the most popular websites online.
WordPress enables you to build and manage your own full-featured website using just your web browser—without having to learn how to code. In fact, if you’ve ever used a text editor like Microsoft Word, you’ll be right at home with the WordPress Editor.
Terraform:
Terraform is an open source “Infrastructure as Code” tool, created by HashiCorp.
A declarative coding tool, Terraform enables developers to use a high-level configuration language called HCL (HashiCorp Configuration Language) to describe the desired “end-state” cloud or on-premises infrastructure for running an application. It then generates a plan for reaching that end-state and executes the plan to provision the infrastructure.
Because Terraform uses a simple syntax, can provision infrastructure across multiple cloud and on-premises data centers, and can safely and efficiently re-provision infrastructure in response to configuration changes, it is currently one of the most popular infrastructure automation tools available. If your organization plans to deploy a hybrid cloud or multicloud environment, you’ll likely want or need to get to know Terraform.
Kubernetes:
Kubernetes is a container management technology developed in Google lab to manage containerized applications in different kind of environments such as physical, virtual, and cloud infrastructure. It is an open source system which helps in creating and managing containerization of application.
AWS RDS Service:
Amazon Relational Database Service (RDS) is a cloud-based managed relational database . AWS handles routine tasks like provisioning, patching, backup, recovery, failure detection, and repair of your databases. RDS utilizes Read Replicas to enhance performance. It can also replicate the database across multiple Availability Zones for durability.
ENVIRONMENT YOU NEED FOR PERFORMING THE TASK:
1.AWS account
2.AWS CLI
3.Terraform environment
4.Minikube (kubernetes) environment
Solution:
1.We have to setup the environment variable in our system
2.We have to write the code for it:
Code for setting Up wordpress in Kubernetes Minikube
provider "kubernetes" { config_context_cluster = "minikube" } resource "kubernetes_deployment" "Webserver-Deployment" { metadata { name = "webserver-deployment" labels = { App = "Webserver" } } spec { replicas = 1 strategy { type = "RollingUpdate" } selector { match_labels = { type = "webserver" env = "Production" } } template { metadata { labels = { type = "webserver" env = "Production" } } spec { container { name = "webserver" image = "wordpress" port { container_port = 80 } } } } } } resource "kubernetes_service" "WordPress" { metadata { name = "wordpress-service" } spec { type = "NodePort" selector = { type = "webserver" } port { port = 80 target_port = 80 protocol = "TCP" name = "http" } } }
save this file kube.tf
Code for setting up RDS in aws
provider "aws" { region = "ap-southeast-1" profile = "default" } resource "aws_db_instance" "WordPress-RDS" { allocated_storage = 5 max_allocated_storage = 10 storage_type = "gp2" engine = "mysql" engine_version = "5.7" instance_class = "db.t2.micro" identifier = "wordpressdb" name = "wpdbtest" username = "task6 ds" password = " " parameter_group_name = "default.mysql5.7" skip_final_snapshot = true port = 3306 publicly_accessible = true auto_minor_version_upgrade = true delete_automated_backups = true } output "RDS-Instance" { value = aws_db_instance.WordPress-RDS.address }
save this file rds.tf
3.Use terraform init command to download plugins for AWS and Kubernetes
"terraform init"
4.configure your aws account
5.go that folder in which you have terraform files and give command
"terraform apply"
after that check AWS GUI
now we are completed with AWS RDS setup.
6.Starting Minikube server
"minikube start"
than
than we can use this command "kubectl get all"
kubectl command to see the services
Thanku for reading );