This package was created as a gloud run demo.
This is an update to my older, now outdated demos (cloud-run-101, cloud-run-102).
$ git clone https://github.com/mitchallen/cloud-run-103.git
Please note that this demo shows how to use services that Google will bill you for.
New users are given a credit and some services are offered for free, below a minimal use.
Be sure to keep an eye on billing and delete test resources when no longer needed.
See: https://console.cloud.google.com/billing
brew install --cask google-cloud-sdk
gcloud init
Run this command to update the components
gcloud components update
For example, I chose us-central1.
gcloud config set run/region us-central1
gcloud services enable \
artifactregistry.googleapis.com \
cloudbuild.googleapis.com \
run.googleapis.com
gcloud auth configure-docker YOUR_REGION-docker.pkg.dev
gcloud artifacts repositories create demo-repo \
--repository-format=docker \
--location=YOUR_REGION \
--description="Docker repo'
Substitute PROJECT-ID with your current gcloud project id:
gcloud builds submit --tag YOUR_REGION-docker.pkg.dev/PROJECT-ID/demo-repo/hello
For the region of us-central1:
gcloud builds submit --tag us-central1-docker.pkg.dev/PROJECT-ID/demo-repo/hello
If you forgot your project ID:
gcloud projects list
You can also check the state of things with:
gcloud info
To see and manage the container image, browse to:
Substitute PROJECT-ID with your current gcloud project id:
gcloud run deploy hello-web --image REGION-docker.pkg.dev/PROJECT-ID/demo-repo/hello
Assuming you don't care if anyone runs your app (as in making it public):
Allow unauthenticated invocations to [hello-web] (y/N)?
If you are concerned about billing, no one will know the URL address if you don't publicly post it anywhere. And you can immediately kill the service when done testing to avoid any unauthorized access or billing.
The command line will then give you the URL of your app, with a message like this (with your own unique URL):
Service [hello-web] revision [hello-web-abcd] has been deployed and is serving 100 percent of traffic at https://hello-web-SOME-RANDOM-ID.a.run.app
Copy the URL and paste the address into a browser or use curl
.
To see and manage the service in the Google Cloud Platform console, browse to:
To save money you should consider taking down private and test resources when not in use. To use them again, be sure to document how to recreate them.
Visit the following console pages to delete test resources:
To delete the service using the command line, run this command:
gcloud run services delete hello-web
To delete the image using the command line (substitute PROJECT-ID with your Google cloud Project ID):
gcloud artifacts docker images delete REGION-docker.pkg.dev/PROJECT-ID/demo-repo/hello
To delete the repo:
gcloud artifacts repositories delete demo-repo
To monitor billing:
- https://console.cloud.google.com
- https://cloud.google.com/run/docs/tutorials/system-packages#follow-cloud-run
- https://github.com/GoogleCloudPlatform/nodejs-docs-samples/tree/master/run/system-package
- https://tapendradev.medium.com/how-to-install-gcloud-sdk-on-the-macos-and-start-managing-gcp-through-cli-d14d2c3a8869