Skip to content

Latest commit

 

History

History
113 lines (89 loc) · 3.26 KB

File metadata and controls

113 lines (89 loc) · 3.26 KB

GSP659 - Build a Website on Google Cloud: Challenge Lab

Task 1. Clone the source repository

  1. Clone repository di cloud shell

    git clone https://github.com/googlecodelabs/monolith-to-microservices.git
    cd ~/monolith-to-microservices
  2. install dependensi nodeJS

    ./setup.sh
  3. Jalankan aplikasi

    cd ~/monolith-to-microservices/monolith
    npm start
  4. Lihat aplikasi di preview web (Preview on port 8080)

Task 2. Create a Docker container with Cloud Build

Create the target Docker repository

  1. Di navigasi menu, pilih Artifact Registry > Repositories.

  2. Buat repository baru dengan nama monolith-demo

  3. Pilih Docker sebagai format dan pilih Region us-central1

Configure authentication

  1. Command untuk mengonfigurasikan autentikasi ke repositori Docker di region us-central1
    gcloud auth configure-docker us-central1-docker.pkg.dev

Deploy the image

  1. Enable Cloud Build API

    gcloud services enable artifactregistry.googleapis.com \
        cloudbuild.googleapis.com \
        run.googleapis.com
  2. Start the build

    gcloud builds submit --tag us-central1-docker.pkg.dev/${GOOGLE_CLOUD_PROJECT}/monolith-demo/monolith:1.0.0
  3. Untuk melihat history build, pilih CI/CD > Cloud Build > History

Task 3. Deploy the container to Cloud Run

  1. Deploy container ke Cloud Run
    gcloud run deploy monolith --image us-central1-docker.pkg.dev/${GOOGLE_CLOUD_PROJECT}/monolith-demo/monolith:1.0.0 --region us-central1

Verify deployment

  1. Untuk memverifikasi deployment
    gcloud run services list

Task 4. Create new revision with lower concurrency

  1. re-deploy container dengan concurrency 1

    gcloud run deploy monolith --image us-central1-docker.pkg.dev/${GOOGLE_CLOUD_PROJECT}/monolith-demo/monolith:1.0.0 --region us-central1 --concurrency 1
  2. Untuk melihat detail, pilih di Navigation Menu > Cloud Run > monolith > Revisions

  3. re-deploy container dengan concurrency 80

    gcloud run deploy monolith --image us-central1-docker.pkg.dev/${GOOGLE_CLOUD_PROJECT}/monolith-demo/monolith:1.0.0 --region us-central1 --concurrency 80

Task 5. Make changes to the website

  1. Mengubah tampilan homepage website

    cd ~/monolith-to-microservices/react-app/src/pages/Home
    mv index.js.new index.js
  2. Menampilkan isi file index.js

    cat ~/monolith-to-microservices/react-app/src/pages/Home/index.js
  3. Build ulang aplikasi

    cd ~/monolith-to-microservices/react-app
    npm run build:monolith
  4. Deploy ulang container dan ganti versi menjadi 2.0.0

    cd ~/monolith-to-microservices/monolith
    gcloud builds submit --tag us-central1-docker.pkg.dev/${GOOGLE_CLOUD_PROJECT}/monolith-demo/monolith:2.0.0

Task 6. Update website with zero downtime

  1. re-deploy
    gcloud run deploy monolith --image us-central1-docker.pkg.dev/${GOOGLE_CLOUD_PROJECT}/monolith-demo/monolith:2.0.0 --region us-central1

Verify deployment

  1. Untuk memverifikasi deployment
    gcloud run services describe monolith --platform managed --region us-central1