Skip to content

Building a stateful web app using GCP architecture to deploy it in GKE cluster using Terraform(IaC)

Notifications You must be signed in to change notification settings

abdelrhman95/GCP-Stateful-WebApp

Repository files navigation

GCP-Terraform-Node.jsApp

Building a stateful web app using GCP architecture to deploy it in the GKE cluster using Terraform as infrastructure as code (IaC)

Overview

  • Develop and use your own Terraform modules to build the required infrastructure on GCP:

    • a. IAM: 2 service accounts - N roles.
    • b. Network: 1 VPC – 2 subnets – N firewall rules – 1 NAT.
    • c. Compute: 1 private VM – 1 GKE standard cluster across 3 zones.
    • d. Storage: Artifact Registry repository to store the images.
  • Deploy the MongoDB replicaset across the 3 zones

  • Dockerize and Deploy the Node.js web app connected to the 3 DB replicas.

  • Expose the web app using ingress/load balancer.

Architecture

Screenshot from 2023-10-26 20-43-58

Prerequisites

  • GCP Account
  • Terraform
  • docker
  • kubectl

Steps

  • Build application image by docker file and push to artifact registry Screenshot from 2023-10-26 21-10-47

  • Initialize infra using Terraform

    terraform init
    terraform plan
    terraform apply --auto-approve
    • after applying it should return that your infra has been completed Screenshot from 2023-10-26 21-19-14
  • After creating the GCP architecture we have to ssh to private-vm through IAP

    gcloud compute ssh [vm-name] --tunnel-through-iap --zone=[zone-name] --project=[project-id]
  • Once you connect to your private VM, you can access the GKE Cluster

    gcloud container clusters get-credentials [cluster-name] --zone [zone-name] --project [project-id]
    • Deploy MongoDB (stateful)
    • Deploy Node.js app
    • Deploy LoadBalancer service

Results

  • k8s

    curl EXTERNAL_IP:PORT

    running application through load balancer

About

Building a stateful web app using GCP architecture to deploy it in GKE cluster using Terraform(IaC)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published