Deploy a Cloud Run service, job, or worker pool

This document describes how to deploy your applications, including Cloud Run services, Cloud Run jobs, and Cloud Run worker pools.

Cloud Deploy lets you to deploy your container-based workloads to any Cloud Run service, job, or worker pool. All Cloud Deploy features are supported when you deploy to Cloud Run targets for Cloud Run services or worker pools, but canary deployments aren't supported for Cloud Run jobs.

This document describes the three main configurations you need to complete in order to deploy to Cloud Run:

Limitations

  • You can only deploy one Cloud Run service, job, or worker pool per target.

  • You can't run a canary deployment against a Cloud Run job.

    Cloud Run services and worker pools, however, can use a canary deployment.

  • To deploy a Cloud Run function using Cloud Deploy, you need to modify your CI workflow to build the function into a container and deploy it as a Cloud Run service.

Before you begin

Create your target configuration

The target can be configured in your delivery pipeline YAML, or can be in a separate file. Also, you can configure more than one target in the same file.

Targets must be defined in the same project and region as the delivery pipeline. But the services, jobs, or worker pools the targets deploy to can be in different projects and regions, as long as the service account has access to those projects.

In the target definition, create a run stanza to identify the location where the Cloud Run service will be created.

The syntax for specifying the Cloud Run service, job, or worker pool in your target definition is as follows:

run:
 location: projects/[project_name]/locations/[region_name]

This resource identifier uses the following elements:

  • project_name is the name of the Google Cloud project in which your Cloud Run service, job, or worker pool will be created.

    You'll do this for each target. We recommend a different project for each Cloud Run service, job, or worker pool. If you want more than one service, job, or worker pool in the same project, you need to use Skaffold profiles in your skaffold.yaml configuration file.

  • region_name is the region in which the service, job, or worker pool will be created. Your service, job, or worker pool can be in any region that Cloud Run supports.

The following is an example target configuration, defining the Cloud Run service, job, or worker pool to create:

      apiVersion: deploy.cloud.google.com/v1
      kind: Target
      metadata:
       name: dev
      description: development service
      run:
       location: projects/my-app/locations/us-central1

You can define this target inside a Cloud Deploy delivery pipeline definition, or separately. Either way, you must register the target before you create the release to deploy your Cloud Run service, job, or worker pool.

Create your Skaffold configuration

The following is an example skaffold.yaml file for a Cloud Run deployment:

apiVersion: skaffold/v4beta7
kind: Config
metadata: 
  name: cloud-run-application