Quickstart: Deploying a Cloud Run service with Cloud Code

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

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

If you're running this quickstart on Apple M-series silicon, your application is built using Cloud Build, which can incur charges. For more information, see Cloud Code support for Apple M-series silicon.

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. In the Google Cloud Console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

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

  7. Enable the Cloud Run API.

    Enable the API

Installing Cloud Code

To install the Cloud Code for IntelliJ plugin:

  1. Install JetBrains IDE version 2020.3+ (such as IntelliJ Ultimate/Community, PyCharm Professional/Community, WebStorm, GoLand), if you haven't already.

  2. If you're running Cloud Code on Apple M-series silicon, install Rosetta 2. This allows Cloud Code to install kubectl as a managed dependency.

    If you prefer not to install Rosetta 2, turn off managed dependencies (IntelliJ IDEA > Preferences > Tools > Cloud Code > Dependencies) and install your own ARM version of kubectl as described in Custom versions of dependencies.

  3. 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 in your PATH.) To check if you already have Docker installed, run docker -v.
    • Cloud Code automatically installs other necessary dependencies.
  4. Open IntelliJ IDEA (or any supported JetBrains IDE).

  5. Once you have your IDE open, refresh this page.

    You can now install the Cloud Code plugin directly by clicking the button below:

    The button launches an installation dialog within your open IDE. Click OK to set up Cloud Code.

Creating a service

To create a new service using an existing sample:

  1. In your IDE, open File > New Project and then select Cloud Code: Cloud Run.
  2. Select the programming language for your sample application and then click Next. Creating a service from a list of existing sample apps
  3. Name your project and then click Finish.

    Cloud Code clones the sample application, opens your newly created project for use, and creates the necessary Cloud Run run configurations.

  4. If you chose a Java sample application, when prompted, click Load Maven project.

    Maven build scripts found notification - choose Load Maven Project, Skip, or Help

You can now run your Hello World service. Cloud Code watches your filesystem for changes so that you can edit and rerun your service in near real time.

Deploying your service to Cloud Run

To deploy your service, follow these steps:

  1. Choose the automatically created run configuration, Cloud Run: Deploy, from the Run/Debug configurations selector in the Navigation bar.

    If you're running this quickstart on Apple M-series silicon, your application is built using Cloud Build. For information about Cloud Build pricing, see Pricing.

  2. Click Run run action icon. This brings up the Edit configuration window.

  3. Set your Google Cloud project ID.

  4. Choose a region for your deployment platform.

    This quickstart uses the default platform option, Cloud Run (fully managed), as the Deployment Platform.

  5. Click Run.

  6. View your running service by following the URL displayed in the output window.

  7. You can also view the status of your service (metrics, revision details, and more) by following the logs URL displayed in the output window.

    Viewing the status of your service in the Cloud Console

Viewing resource status

To view the status of your running service's resources, follow these steps:

  1. Navigate to the Cloud Run Explorer. It can be accessed from the sidebar panel on the right.

    Cloud Run explorer tab highlighted on the right hand-side panel

  2. To display a service or revision's properties, click the service or revision in the explorer.

    Cloud Run explorer open with a service selected and its properties displayed below

  3. To view a revision's logs, right-click the revision and then click View Cloud Logs.

    Right-click a revision to view its logs

Cleaning up

If you created a project for this quickstart, be sure to delete it to avoid unnecessary charges:

  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.

    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 doesn't charge when the service isn't in use, you might still be charged for storing the container image in Container Registry. To delete your image, follow the steps in Deleting images.
  • Cloud Run service: To delete a Cloud Run service, navigate to Cloud Run in the Cloud Console using the navigation menu. Select the service you'd like to delete and then click Delete.

What's next

Getting support

To submit feedback or report an issue in your IntelliJ IDE, go to Tools > Cloud Code > Help / About > Submit feedback or report an issue to report an issue on GitHub, or ask a question on Stack Overflow.

You can also join the #cloud-code channel, which is part of the Google Cloud Slack community.