HYBRID MULTI-CLOUD TASK-6

 


Now this is the last task of Hybrid Multi-cloud assigned by our mentor Sir Vimal Daga. 

Thank you sir for such an amazing and mind blowing training. I am glad to be the part of LINUX WORLD. 

Task-6

AWS

AWS (Amazon Web Services) is a comprehensive, evolving cloud computing platform provided by Amazon that includes a mixture of infrastructure as a service (IAAS), platform as a service (PAAS) and packaged software as a service (SAAS) offerings. AWS services can offer an organisation tools  such as compute power, database storage and content delivery services. The "cloud" is a set of different types of hardware and software that work collectively to deliver many aspects of computing to the end-user as an online service.Cloud Computing is the use of hardware and software to deliver a service over a network (typically the Internet). With cloud computing, users can access files and use applications from any device that can access the Internet. 

Terraform

Terraform is an open-source infrastructure as code software tool created by HashiCorp. Users define and provision data center infrastructure using a declarative configuration language known as HashiCorp Configuration Language (HCL), or optionally json.

Terraform manages external resources (such as public cloud infrastructure, private cloud infrastructure, network appliances, software as a service, and platform as a service) with "providers". HashiCorp maintains an extensive list of official providers, and can also integrate with community-developed providers. Users can interact with Terraform providers by declaring resources or by calling data sources.[Rather than using imperative commands to provision resources, Terraform uses declarative configuration to state the desired final state. Once a user invokes Terraform on a given resource, Terraform will perform CRUD actions on the user's behalf to accomplish the desired state. The infrastructure as code can be written as modules, promoting reusability and maintainability.

Kubernetes

Kubernetes is a portable, extensible, open-source platform for managing containerized workloads and services, that facilitates both declarative configuration and automation. It has a large, rapidly growing ecosystem. Kubernetes services, support, and tools are widely available.

Kubernetes provides you with:

  • Service discovery and load balancing Kubernetes can expose a container using the DNS name or using their own IP address. If traffic to a container is high, Kubernetes is able to load balance and distribute the network traffic so that the deployment is stable.
  • Storage orchestration Kubernetes allows you to automatically mount a storage system of your choice, such as local storages, public cloud providers, and more.
  • Automated rollouts and rollbacks You can describe the desired state for your deployed containers using Kubernetes, and it can change the actual state to the desired state at a controlled rate. For example, you can automate Kubernetes to create new containers for your deployment, remove existing containers and adopt all their resources to the new container.
  • Automatic bin packing You provide Kubernetes with a cluster of nodes that it can use to run containerized tasks. You tell Kubernetes how much CPU and memory (RAM) each container needs. Kubernetes can fit containers onto your nodes to make the best use of your resources.
  • Self-healing Kubernetes restarts containers that fail, replaces containers, kills containers that don't respond to your user-defined health check, and doesn't advertise them to clients until they are ready to serve.
  • Secret and configuration management Kubernetes lets you store and manage sensitive information, such as passwords, OAuth tokens, and SSH keys. You can deploy and update secrets and application configuration without rebuilding your container images, and without exposing secrets in your stack configuration

RDS

 Amazon Relational Database Service (Amazon RDS) makes it easy to set up, operate, and scale a relational database in the cloud. It provides cost-efficient and resizable capacity while automating time-consuming administration tasks such as hardware provisioning, database setup, patching and backups. It frees you to focus on your applications so you can give them the fast performance, high availability, security and compatibility they need.

Amazon RDS is available on several database instance types - optimized for memory, performance or I/O - and provides you with six familiar database engines to choose from, including Amazon AuroraPostgreSQLMySQLMariaDBOracle Database, and SQL Server. You can use the AWS Database Migration Service to easily migrate or replicate your existing databases to Amazon RDS.

Task Assigned

 Deploy the Wordpress application on Kubernetes and AWS using terraform including the following steps;

  •  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 
  •  The Wordpress application should be accessible from the public world  through workstation.
Prerequisites: 
  • Create Aws account,
  • Download credentials after launching a user via IAM service
  • Install minikube 
Lets begin:
Step 1: we write the code kubernetes service

Code:
provider "kubernetes" {
  config_context_cluster = "minikube"
}

resource "kubernetes_service" "kub_ser_rn" {
  metadata {
    name = "wordpress-service"
  }
  spec {
    selector = {
      app = "wordpress"
    }
    
    port {
      node_port = 30000
      port        = 80
      target_port = 80
    }

    type = "NodePort"
  }
}





resource "kubernetes_deployment" "dep_rn" {
  metadata {
    name = "wordpress"
   labels = {
          env = "prod"
        }
  }

  spec {
    replicas = 1

    selector {
      match_labels = {
        env = "prod"
      }
    }

    template {
      metadata {
        labels = {
          env = "prod"
        }
      }

      spec {
          
        container {
          image = "wordpress:4.8-apache"
          name  = "wordpress"
            port{
                container_port = 80
            }
        }
      }
    }
  }
}

Step 2:Initialize the code and validate the code
Command : 
  • terraform init
  • terraform validate
Step 3: Run the code
Command: terraform apply




Step 4we will check the nodes from our CLI via command kubectl get all


Step 5: We write the code for RDS
Code:
provider "aws" {
  region  = "ap-south-1"
profile = "saba9554"
}
resource "aws_db_instance" "rds_rn" {
  allocated_storage    = 5
  max_allocated_storage = 10
  storage_type         = "gp2"
  engine               = "mysql"
  engine_version       = "5.7"
  instance_class       = "db.t2.micro"
  name                 = "mydb_task6"
  username             = "task"
  password             = "taskdb123"
  parameter_group_name = "default.mysql5.7"
  port = 3306
  publicly_accessible = true
}
 We initialize and validate the code
And we run the code



Step 6: 
 Note the ip of minikube, then we will connect to our wordpress


Comments

Popular posts from this blog

Flutter Task-1

Launching Web-app through Terraform

HYBRID MULTI-CLOUD TASK-4