Sunday, May 29, 2022
GCP

Serverless Cloud Run Development: Challenge Lab

Run

“Serverless Cloud Run Development: Challenge Lab”

Solusi

Provision the Qwiklabs environment:

Open the cloud shell and Run the commands one by one:

gcloud config set project \
  $(gcloud projects list --format='value(PROJECT_ID)' \
  --filter='qwiklabs-gcp')

gcloud config set run/region us-central1

gcloud config set run/platform managed

git clone https://github.com/rosera/pet-theory.git && cd pet-theory/lab07

The above steps are written in the Challenge lab itself so they are basically not new :)

Now talking about these tasks are all almost same so no need to worry about, if you watched the video on this so the basic template is :

cd [ directory_name ]
gcloud builds submit --tag gcr.io/[PROJECT_ID]/[API_NAME]
gcloud run deploy --image gcr.io/[PROJECT_ID]/[API_NAME]

Task 1: Enable a Public Service

First Run the below commands :

cd unit-api-billing
gcloud builds submit --tag gcr.io/[PROJECT_ID]/billing-staging-api:0.1
gcloud run deploy --image gcr.io/[PROJECT_ID]/billing-staging-api:0.1

After pressing "Enter" they will ask for Service Name so paste this :
public-billing-service

What ever they ask press Yes (Y) and us-central1 if that was region 

Task-2

Run these commands:
cd ..
cd staging-frontend-billing
gcloud builds submit --tag gcr.io/[PROJECT_ID]/frontend-staging:0.1
gcloud run deploy --image gcr.io/[PROJECT_ID]/frontend-staging:0.1


After pressing "Enter" they will ask for Service Name so paste this :
Enter: frontend-staging-service

What ever they ask press Yes (Y) and us-central1 if that was region 

Task 3: Deploy a Private Service

Run these commands:
cd ..
cd staging-api-billing

Go to Navigation menu > Cloud Run. 
Delete the service named as: public-billing-service

Return to the cloud shell window and execute these commands:

gcloud builds submit --tag gcr.io/[PROJECT_ID]/billing-staging-api:0.2
gcloud run deploy --image gcr.io/[PROJECT_ID]/billing-staging-api:0.2

For the Service name Enter: private-billing-service

What ever they ask press Yes (Y) and us-central1 if that was region 

Then write this in the Shell :

export BILLING_SERVICE=private-billing-service

BILLING_URL=$(gcloud run services describe $BILLING_SERVICE \
  --platform managed \
  --region us-central1 \
  --format "value(status.url)")

curl -X get -H "Authorization: Bearer $(gcloud auth print-identity-token)" $BILLING_URL

Task 4: Create a Billing Service Account

Go to Navigation menu > IAM & Admin > Service accounts
Click on Create Service account.
Give name as: billing-service-sa

Accept all the default values and click on Done.

Task 5: Deploy the Billing Service

execute these commands in Cloud shell:

cd ..
cd prod-api-billing

gcloud builds submit --tag gcr.io/[PROJECT_ID]/billing-prod-api:0.1
gcloud run deploy --image gcr.io/[PROJECT_ID]/billing-prod-api:0.1 --service-account billing-service-sa

For the Service name Enter: billing-prod-service

What ever they ask press Yes (Y) and us-central1 if that was region 


Then enter these commands:

export PROD_BILLING_SERVICE=billing-prod-service

PROD_BILLING_URL=$(gcloud run services \
  describe $PROD_BILLING_SERVICE \
  --platform managed \
  --region us-central1 \
  --format "value(status.url)")

curl -X get -H "Authorization: Bearer \
  $(gcloud auth print-identity-token)" \
  $PROD_BILLING_URL

Task 6: Frontend Service Account

Go to Navigation menu > IAM & Admin > Service accounts
Click on Create Service account.
Give name as: frontend-service-sa
Give the Role: Cloud Run Invoker

Accept all other default values and click on Done.

Task 7: Redeploy the Frontend Service

Execute these commands in Cloud shell:

cd ..
cd prod-frontend-billing

gcloud builds submit --tag gcr.io/[PROJECT_ID]/frontend-prod:0.1
gcloud run deploy --image gcr.io/[PROJECT_ID]/frontend-prod:0.1 --service-account frontend-service-sa

What ever they ask press Yes (Y) and us-central1 if that was region 

Penutup

Baca Juga :  Continuous Delivery with Jenkins in Kubernetes Engine

Sahabat Blog Learning & Doing demikianlah penjelasan mengenai Serverless Cloud Run Development: Challenge Lab. Semoga Bermanfaat . Sampai ketemu lagi di postingan berikut nya.

(Visited 25 times, 1 visits today)
Klik untuk berbagi dengan orang lain

Similar Posts