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

To use Cloud Run, you'll need to create a GCP project and enable billing.

Installing Cloud Code

  1. Install Visual Studio 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 respective 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, refer to this guide on how to set up your Docker client.
      • If you're using WSL but cannot install Docker for Desktop, use minikube instead for local development with Cloud Code.
    • Cloud Code will automatically install kubectl, Skaffold, and Google Cloud SDK.
  3. Install Cloud Code using one of these options:
    • Use this link to open VS Code and install Cloud Code.
    • Open Visual Studio 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.
  4. Once the installation is complete, you'll see the Cloud Code Welcome page and a collection of built-in templates under Starter Apps which 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, you can click Deploy.

    Cloud Code then 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 on its icon in the VS Code Activity bar on the left Cloud Run explorer icon.
  2. Right-click on your Cloud Run service and choose View logs.

    Viewing logs for a non-Cloud Logging cluster by setting the deployment field within 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 on its icon in the VS Code Activity bar on the left Cloud Run explorer icon.
  2. Click on the Cloud Run service you'd like to know more about. Its 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:

  • Go to the Projects page in the Cloud Console:

    Go to the Projects page

  • Select the project you created for this Quickstart and click on the trash can icon next to delete it.

    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:

  • Container image: While Cloud Run does not charge when the service is not in use, you might still be charged for storing the container image in Container Registry. To delete your image, follow this guide.

  • Cloud Run service: To delete a Cloud Run service, navigate to Cloud Run in the Console using the navigation menu. Select the service you'd like to delete and click on the Delete trash can icon.

What's next