Deploying a Cloud Run service

This page shows you how to get started quickly with Cloud Code.

You'll set up a Hello World service that runs on Cloud Run using a starter template, deploy your service to Cloud Run, and view the status of your live service's resources.

Before you begin

  1. Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
  2. In the Google Cloud Console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  3. Make sure that billing is enabled for your Cloud project. Learn how to confirm that billing is enabled for your project.

  4. Enable the Cloud Run API.

    Enable the API

  5. Install Git. Git is required for copying samples to your machine.

Installing Cloud Code

  1. Install VS Code on your machine, if you haven't already.
  2. Install dependencies:
    • For all Cloud platforms, ensure the Docker client (authenticated with your Docker registry) is installed on the PATH of your machine (its folder should be visible under a directory within your PATH).
      • To check if you already have Docker installed, run docker -v.
      • If you're using Windows Home, see Get started developing with Docker Desktop for steps to set up your Docker client.
      • If you're using WSL but can't install Docker for Desktop, use minikube instead for local development with Cloud Code.
    • Cloud Code automatically installs kubectl, Skaffold, and Cloud SDK.
  3. Install Cloud Code using one of these options:

    • Use this link to open VS Code and install Cloud Code.
    • Open VS Code on your machine. Using the Extensions view Extension icon in VS Code (its square icon available on the left side taskbar), search for the Cloud Code extension and click Install.

    After the installation is complete, you'll see the Cloud Code Welcome page and a collection of built-in templates under Starter Apps that you can use to quickly set up a new service.

    Welcome page

Creating a service

  1. From the Cloud Code status bar, select New Application. Creating a new service with the Cloud Code status bar
  2. Choose Cloud Run application as your preferred application type.
  3. From the list of templates (Node.js, Python (Flask and Django frameworks), Java, Go), choose a Hello World service in a language of your choosing.

    For example, choosing Node.js: Hello World will create a starter Node.js Hello World service.

  4. Confirm your service location (or modify it, if necessary) to proceed.

    A notification will confirm your service has been created and a new window with your service will open.

Deploy to Cloud Run

To deploy your service to Cloud Run, follow these steps:

  1. Choose the Deploy to Cloud Run command using the Cloud Code status bar.

    This brings up the Cloud Run: Deploy UI. Cloud Run: Run/Debug Locally UI with pre-existing service selected

  2. Set your Google Cloud project.

  3. Select a pre-existing service or create a new one.

  4. If you're creating a new service, choose Cloud Run (fully managed) under Deployment Platform.

  5. Choose a region to deploy to.

  6. After you define your preferred settings, click Deploy.

    Cloud Code builds your image, pushes it to the registry, and deploys your service to Cloud Run. Your service is now live!

  7. View your running service by following the URL displayed in the webview.

Viewing logs

You can also view logs from your deployed service with the Log Viewer that comes with Cloud Code.

To view logs, follow these steps:

  1. Navigate to the Cloud Run explorer by clicking Cloud Run explorer icon Cloud Code - Cloud Run in the VS Code Activity bar on the left.
  2. Right-click your Cloud Run service and then click View logs.

    Viewing logs for a non-Cloud Logging cluster by setting the deployment field in the Log Viewer search box to 'node-guestbook'

Viewing resource status

You can view the status of your Cloud Run services using the Cloud Run service browser:

  1. Navigate to the Cloud Run explorer by clicking its icon in the VS Code Activity bar on the left Cloud Run explorer icon.
  2. Click the Cloud Run service you'd like to know more about. The service's properties are displayed in the window below.

    Properties of a selected service displayed below in the Cloud Run Explorer

Cleaning up

To delete your project:

  1. Go to the Projects page in the Google Cloud Console:

    Go to the Projects page

  2. Select the project you created for this quickstart and then click Delete.

  3. Type the project ID to confirm and then click Shut down.

    This shuts down the project and schedules it for deletion.

If you're using a pre-existing project and would like to delete resources you created for this quickstart:

What's next