Roadmaps / DevOps & Cloud / Lab 7

Lab 7 of 8 · Deploying to the cloud

Deploy your container to Google Cloud Run

Deploy your app to a public HTTPS address on Google Cloud Run, check it, and delete it, with a budget alert protecting you.

Time
60 minutes
Cost
Needs a Google Cloud account with a card. This lab normally stays inside Google's free tier, but set the budget alert in step 2 and do the clean-up step so nothing keeps running.

What you learn

The cloud rents you computers, networks and managed services by the minute. Here you deploy your container to a managed service, protect yourself with a budget alert, and clean up afterwards.

  • Cloud accounts, projects, regions and billing
  • Identity and access management (IAM) basics
  • Serverless containers: deploy without managing servers
  • Budget alerts and cleaning up

In the AI era: Managed AI services (Amazon Bedrock, Azure AI Foundry, Google Vertex AI) live in the same cloud accounts and use the same IAM, networking and billing you learn here.

Before you start

  • Finish lab 2.

  • Install the Google Cloud CLI and run gcloud init.

  • Use a new project just for labs, so deleting it removes everything.

Step by step

  1. 1 Create a project for labs

    Project IDs must be unique worldwide: change the numbers at the end. Then link a billing account in the console (Billing → Link a billing account).

    Run this
    gcloud projects create ai-status-lab-12345 --name="AI Status Lab"
    gcloud config set project ai-status-lab-12345
  2. 2 Set a budget alert first

    In the console, open Billing → Budgets & alerts → Create budget. Set the amount to 5 (in your currency) and keep the 50%, 90% and 100% email alerts. This emails you; it does not stop spending, which is why the clean-up step matters.

  3. 3 Turn on the services Cloud Run needs

    Google Cloud services are off until you enable them.

    Run this
    gcloud services enable run.googleapis.com cloudbuild.googleapis.com artifactregistry.googleapis.com
  4. 4 Deploy from your source code

    Cloud Run builds your Dockerfile in the cloud and runs it. Answer Y if it asks to create an Artifact Registry repository. --allow-unauthenticated makes it public, which is fine for this demo app.

    Run this
    gcloud run deploy ai-status-app --source . --region us-central1 --allow-unauthenticated --port 8000 --max-instances 1
    You should see:

    A Service URL: https://ai-status-app-....run.app line.

  5. 5 Check it and read the logs

    Replace the address with your Service URL.

    Run this
    curl https://YOUR-SERVICE-URL/health
    gcloud run services logs read ai-status-app --region us-central1 --limit 20
    You should see:

    {"status":"ok"} over HTTPS, and request lines in the logs.

  6. 6 Look at who can do what

    IAM decides which people and services can change your project. Notice the service account Cloud Run uses; least privilege means giving it only what it needs.

    Run this
    gcloud projects get-iam-policy "$(gcloud config get-value project)" --format="table(bindings.role, bindings.members)"
  7. 7 Clean up

    Delete the service. To remove everything this lab created, delete the whole lab project (it is removed after 30 days).

    Run this
    gcloud run services delete ai-status-app --region us-central1
    # optional, removes everything:
    gcloud projects delete "$(gcloud config get-value project)"
  8. 8 Record it in your README

    Add a "Deployment" section to README.md with the deploy command and a screenshot of the working URL, then push.

    Run this
    git add README.md
    git commit -m "Document the Cloud Run deployment"
    git push

You are done when

  • Your app answered over HTTPS on a run.app address.

  • A budget alert exists on your billing account.

  • You deleted the service (and, if you chose, the project) afterwards.

Finished? Get your proof page

We check your public GitHub repository and give you a page to share with recruiters, and can add the project to your resume.