Deploy an app to Cloud Run using Cloud Deploy

This page shows you how to use Cloud Deploy to deliver a sample application image named hello to a sequence of two Cloud Run services, two Cloud Run jobs, or two Cloud Run worker pools.

In this quickstart, you'll do the following:

  1. Create a Skaffold configuration

  2. Create configuration files for two Cloud Run services, two jobs, or two worker pools.

    These files define the services or jobs, and specify the (pre-built) container images to deploy.

  3. Define your Cloud Deploy delivery pipeline and deployment targets, which point to the two services, the two jobs, or the two worker pools.

  4. Instantiate your delivery pipeline by creating a release, which automatically deploys to the first target.

  5. Promote the release to the second target.

  6. View both rollouts in Google Cloud console.

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.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  3. If you're using an existing project for this guide, verify that you have the permissions required to complete this guide. If you created a new project, then you already have the required permissions.

  4. Verify that billing is enabled for your Google Cloud project.

  5. Enable the Cloud Deploy, Cloud Build, Cloud Run, and Cloud Storage APIs.

    Roles required to enable APIs

    To enable APIs, you need the serviceusage.services.enable permission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.

    Enable the APIs

  6. Install the Google Cloud CLI.

  7. If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

  8. To initialize the gcloud CLI, run the following command:

    gcloud init
  9. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  10. If you're using an existing project for this guide, verify that you have the permissions required to complete this guide. If you created a new project, then you already have the required permissions.

  11. Verify that billing is enabled for your Google Cloud project.

  12. Enable the Cloud Deploy, Cloud Build, Cloud Run, and Cloud Storage APIs.

    Roles required to enable APIs

    To enable APIs, you need the serviceusage.services.enable permission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.

    Enable the APIs

  13. Install the Google Cloud CLI.

  14. If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

  15. To initialize the gcloud CLI, run the following command:

    gcloud init

Required roles

To ensure that the Cloud Deploy service account has the necessary permissions to run Cloud Deploy operations and deploy to Cloud Run, ask your administrator to grant the following IAM roles to the Cloud Deploy service account on your project:

For more information about granting roles, see Manage access to projects, folders, and organizations.

Your administrator might also be able to give the Cloud Deploy service account the required permissions through custom roles or other predefined roles.

Prepare your Skaffold configuration

Cloud Deploy uses Skaffold to provide the details for what to deploy and how to deploy it properly for your separate targets.

For this quickstart, you create a skaffold.yaml file, which identifies the Cloud Run service or job definition to be used to deploy the sample app.

  1. Open a terminal window.

  2. Create a new directory, named deploy-run-quickstart and navigate into it.

    mkdir deploy-run-quickstart
    cd deploy-run-quickstart
    
  3. Create a file named skaffold.yaml with the following contents:

    Services

    apiVersion: skaffold/v4beta7
    kind: Config
    metadata: 
      name: deploy-run-quickstart
    profiles:
    - name: dev
      manifests:
        rawYaml:
        - run-service-dev.yaml
    - name: prod
      manifests:
        rawYaml:
        - run-service-prod.yaml
    deploy:
      cloudrun: {}
    

    Jobs

    apiVersion: skaffold/v4beta7
    kind: Config
    metadata: 
      name: deploy-run-quickstart
    profiles:
    - name: dev
      manifests:
        rawYaml:
        - run-job-dev.yaml
    - name: prod
      manifests:
        rawYaml:
        - run-job-prod.yaml
    deploy:
      cloudrun: {}
    

    Worker pools

    apiVersion: skaffold/v4beta7
    kind: Config
    metadata:
      name: deploy-run-quickstart
    profiles:
    - name: dev
      manifests:
        rawYaml:
        - run-worker-pool-dev.yaml
    - name: prod
      manifests:
        rawYaml:
        - run-worker-pool-prod.yaml
    deploy:
      cloudrun: {}
    

    This file is a minimal Skaffold config, identifying your Cloud Run services, jobs, or worker pools. See the