HYBRID MULTI CLOUD TASK 6  | |                     Deploy the word-press application on K8S and AWS using Terraform

HYBRID MULTI CLOUD TASK 6 | | Deploy the word-press application on K8S and AWS using Terraform

Hello Guys, back with another article. In this article you will find a word press application has been launched using Kubernetes on AWS using terraform.

So let's start this task. Launch a Minikube virtual machine on Oracle VM. Start the Minikube and do all the installation requirements.

No alt text provided for this image

Then you need to Install Kubernetes on Windows or linux. Here, i have installed Kubernetes on Windows.

After that write the write the below code to launch the Kubernetes pods.

provider "kubernetes"{
   config_context_cluster = "minikube"
}


resource "kubernetes_deployment"  "test1" {
     metadata {
       name="wordpress"
       labels={
            test="wp"
            }
              }
             
        spec {
      replicas =3
      selector {
        match_labels = {
             test = "wp"
                    }
           }
        template{
          metadata{
          labels={
             test = "wp"
              }
            }
          spec{
          container{
          image="wordpress:4.8-apache"
          name="wprdpress"
           }
         }
        }
       }
      }


resource "kubernetes_service" "lb1"{
     metadata{
     name="lb"
     }
     spec {
     selector ={
     test = "wp"
     }
     port{
     node_port = 31000
     port      = 80
     target_port = 80
     }
     type= "NodePort"
    }
  }
   

Then we have to run this code.

terraform apply

This will launch Wordpress on a pod launched by terraform.

No alt text provided for this image

As you can see we have launched, The wordpress.

Now, we have to launch the Amazon RDS. in which we have to launch MYSQL Data base.

provider "aws"{
 region = "ap-south-1"
 profile = "Amit"
}
resource "aws_db_instance"  "mydb"{
   allocated_storage = 10 
   storage_type = "gp2"
   engine = "mysql"
   engine_version = "5.7"
   instance_class = "db.t2.micro"
   name           = "RDS_db"
   username = "amit"
   password = "amit123"
   port     = "3306"
   parameter_group_name = "default.mysql5.7"
   iam_database_authentication_enabled = true
   publicly_accessible = true
   skip_final_snapshot = true
   tags = {
     Name = "mydb"
  }
}

We have to launch MYSQL database using terraform on AWS inside RDS.

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

Now as you can see the Amazon RDS is launched successfully.

No alt text provided for this image

As you can see that we have launched Wordpress successfully.

No alt text provided for this image


Hope you had liked my article. like and comment !!

Thank You !




Vishal Dhole

SDE @Sarvaha Systems | Full Stack Web Developer | Angular | Node.js | Problem Solving | AWS

4 年

Good work

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

Amit Sharma的更多文章

社区洞察

其他会员也浏览了