GSP-328: Serverless Cloud Run Development
Overview
Start by executing the following commands:
1gcloud auth list
2gcloud config list project
3
4gcloud config set project \
5$(gcloud projects list --format='value(PROJECT_ID)' \
6--filter='qwiklabs-gcp')
7
8gcloud config set run/region us-central1
9gcloud config set run/platform managed
10
11git clone https://github.com/rosera/pet-theory.git && cd pet-theory/lab07
12export PROJECT_ID=$(gcloud info --format='value(config.project)')
Task - 1 : Deploy a Public Billing Service
1cd ~/pet-theory/lab07/unit-api-billing
2
3gcloud builds submit --tag gcr.io/${PROJECT_ID}/billing-staging-api:0.1
4gcloud run deploy public-billing-service --image gcr.io/${PROJECT_ID}/billing-staging-api:0.1
5
6gcloud run services list
Task - 2 : Deploy the Frontend Service
1cd ~/pet-theory/lab07/staging-frontend-billing
2
3gcloud builds submit --tag gcr.io/${PROJECT_ID}/frontend-staging:0.1
4gcloud run deploy public-billing-service --image gcr.io/${PROJECT_ID}/frontend-staging:0.1
5
6gcloud run services list
Task - 3 : Deploy a Private Billing Service
1cd ~/pet-theory/lab07/staging-api-billing
2
3gcloud builds submit --tag gcr.io/${PROJECT_ID}/billing-staging-api:0.2
4gcloud run deploy public-billing-service --image gcr.io/${PROJECT_ID}/billing-staging-api:0.2
5
6gcloud run services list
7
8BILLING_URL=$(gcloud run services describe $BILLING_SERVICE \
9 --platform managed \
10 --region us-central1 \
11 --format "value(status.url)")
12
13curl -X get -H "Authorization: Bearer $(gcloud auth print-identity-token)" $BILLING_URL
Task - 4 : Create a Billing Service Account
1gcloud iam service-accounts create billing-service-sa --display-name "Billing Service Cloud Run"
Task - 5 : Deploy a Billing Service in Production
1cd ~/pet-theory/lab07/prod-api-billing
2
3gcloud builds submit --tag gcr.io/${PROJECT_ID}/billing-prod-api:0.1
4gcloud run deploy public-billing-service --image gcr.io/${PROJECT_ID}/billing-prod-api:0.1
5
6gcloud run services list
7
8PROD_BILLING_SERVICE=private-billing-service
9
10PROD_BILLING_URL=$(gcloud run services \
11 describe $PROD_BILLING_SERVICE \
12 --platform managed \
13 --region us-central1 \
14 --format "value(status.url)")
15
16curl -X get -H "Authorization: Bearer \
17 $(gcloud auth print-identity-token)" \
18 $PROD_BILLING_URL
Task - 6 : Create a Frontend Service Account
1gcloud iam service-accounts create frontend-service-sa --display-name "Billing Service Cloud Run Invoker"
Task - 7 : Deploy the Frontend Service in Production
1cd ~/pet-theory/lab07/prod-frontend-billing
2
3gcloud builds submit --tag gcr.io/${PROJECT_ID}/frontend-prod:0.1
4gcloud run deploy public-billing-service --image gcr.io/${PROJECT_ID}/frontend-prod:0.1
5
6gcloud run services list
Congratulations, you're all done with the lab 😄