DEPLOY WORDPRESS ON KUBERNETES AND INTEGRATING IT WITH AWS RDS

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.

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.

No alt text provided for this image

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"

No alt text provided for this image

4.configure your aws account

5.go that folder in which you have terraform files and give command

"terraform apply"

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

after that check AWS GUI

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

now we are completed with AWS RDS setup.

6.Starting Minikube server

"minikube start"

No alt text provided for this image

than

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

than we can use this command "kubectl get all"

kubectl command to see the services

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

Thanku for reading );

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

Vijay Yadav的更多文章

  • JAVA VIRTUAL MACHINE(JVM)

    JAVA VIRTUAL MACHINE(JVM)

    A Java virtual machine is a virtual machine that enables a computer to run Java programs as well as programs written in…

  • How IBM using quantum computing

    How IBM using quantum computing

    What is quantum computing? Quantum computing is a rapidly-emerging technology that harnesses the laws of quantum…

  • How Kubernetes is used in Industries and what use cases solved by Kubernetes

    How Kubernetes is used in Industries and what use cases solved by Kubernetes

    Kubernetes is an open-source container-orchestration system for automating computer application deployment, scaling…

  • Industry Use case on Automation Using Ansible

    Industry Use case on Automation Using Ansible

    This session was organized by two experts from Redhat => Sreejith Anujan The Principal Instructor at Red Hat…

  • How ansible helps in solving challenges faced by big industries?

    How ansible helps in solving challenges faced by big industries?

    What is Ansible? Ansible is an open source automation platform. It is a simple automation language that can perfectly…

    2 条评论
  • Create High Availability Architecture with AWS CLI

    Create High Availability Architecture with AWS CLI

    Amazon CloudFront Amazon CloudFront is a fast content delivery network (CDN) service that securely delivers data…

  • MENU PROGRAM

    MENU PROGRAM

    Task Description : Create a Menu Using Python integrating all the concepts that have been taught by Vimal sir till now.…

    2 条评论
  • How company are benefited by artificial intelligence

    How company are benefited by artificial intelligence

    Artificial Intelligence : Artificial intelligence (AI) refers to the simulation of human intelligence in machines that…

  • WORKING WITH AWS CLI

    WORKING WITH AWS CLI

    he AWS Command Line Interface (CLI) is a unified tool to manage your AWS services. With just one tool to download and…

  • AWS case studies

    AWS case studies

    Amazon Web Services (AWS) AWS (Amazon Web Services) is a comprehensive, evolving cloud computing platform provided by…

    1 条评论

社区洞察

其他会员也浏览了