Deploying a service

This page shows you how to deploy a service to Cloud Run using Google Cloud Code.

Deploying a service to Cloud Run

To deploy your service to Cloud Run:

  1. Choose the Deploy to Cloud Run command using the Command Palette (accessible with Ctrl/Cmd+Shift+P).

    This brings up the Cloud Run Deployment UI.

    Cloud Run: Deployment UI with pre-existing service selected

  2. Set your Google Cloud project.

  3. Select a preexisting service or create a new one.

  4. If you're creating a new service, choose your platform preferences under Deployment Platform, either Cloud Run (fully managed) or Cloud Run for Anthos. For help choosing the best option for your development needs, see the Choosing your platform guide.

  5. If you selected Cloud Run (fully managed), choose a region to deploy to. If you selected Cloud Run for Anthos, configure the Kubernetes cluster information. The cluster must have Anthos support enabled.

  6. You can also specify additional settings like service account, environment variables, and SQL connections, using the Advanced revision settings section.

    The following environment variables are automatically added to the running containers:

    Name Description Example
    PORT The port your HTTP server should listen on. 8080
    K_SERVICE The name of the Cloud Run service being run. hello-world
    K_REVISION The name of the Cloud Run revision being run. hello-world.1
    K_CONFIGURATION The name of the Cloud Run configuration that created the revision. hello-world

  7. Specify your builder (Docker or Buildpack) and its settings.

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

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

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

    You can also view details of your running service by clicking the Show Detailed Logs button and looking through your verbose logs in the output window.

    URL of the running service displayed in Deploy to Cloud Run UI and Show detailed logs button underneath

  10. After your session completes, additional contextual menu options are available to monitor your application and its resources using the Cloud Code status bar, including:

    • Open Deployment Logs: Open the application logs of a specific deployment with the Cloud Code Logs Viewer
    • Open Service URL: Open the application service URL of a specific service in a web browser
    • Turn on/off watch mode: Toggle watch mode for the current session (not available for debug sessions). By default, Cloud Code continuously watches the file system for changes to your files, such as Kubernetes config or code, rebuilds the container(s), and redeploys the application to the cluster so that your edits are reflected in near real time.

      Options available via the Cloud Code status bar: Open Deployment Logs, Open Service URL, and Turn on Watch mode, in addition to regular Cloud Code actions

Getting Support

To send feedback, report issues on GitHub, or ask a question on Stack Overflow.