Quickstart: Deploy a sample worker pool to Cloud Run

This page shows you how to deploy a sample worker pool container. After deploying, the worker pool continually writes a log message.

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. Verify that billing is enabled for your Google Cloud project.

  4. Make sure that you have the following role or roles on the project: Cloud Run Admin, Cloud Run Developer, Logs Viewer

    Check for the roles

    1. In the Google Cloud console, go to the IAM page.

      Go to IAM
    2. Select the project.
    3. In the Principal column, find all rows that identify you or a group that you're included in. To learn which groups you're included in, contact your administrator.

    4. For all rows that specify or include you, check the Role column to see whether the list of roles includes the required roles.

    Grant the roles

    1. In the Google Cloud console, go to the IAM page.

      Go to IAM
    2. Select the project.
    3. Click Grant access.
    4. In the New principals field, enter your user identifier. This is typically the email address for a Google Account.

    5. In the Select a role list, select a role.
    6. To grant additional roles, click Add another role and add each additional role.
    7. Click Save.
  5. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

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

  7. Make sure that you have the following role or roles on the project: Cloud Run Admin, Cloud Run Developer, Logs Viewer

    Check for the roles

    1. In the Google Cloud console, go to the IAM page.

      Go to IAM
    2. Select the project.
    3. In the Principal column, find all rows that identify you or a group that you're included in. To learn which groups you're included in, contact your administrator.

    4. For all rows that specify or include you, check the Role column to see whether the list of roles includes the required roles.

    Grant the roles

    1. In the Google Cloud console, go to the IAM page.

      Go to IAM
    2. Select the project.
    3. Click Grant access.
    4. In the New principals field, enter your user identifier. This is typically the email address for a Google Account.

    5. In the Select a role list, select a role.
    6. To grant additional roles, click Add another role and add each additional role.
    7. Click Save.
  8. Make sure that you have the Service Account User role granted on the service identity. By default, the service identity is the Compute Engine default service account.

    Grant the roles

    To grant access on the service identity resource, use the gcloud iam service-accounts add-iam-policy-binding command, replacing the highlighted variables with the appropriate values:

          gcloud iam service-accounts add-iam-policy-binding SERVICE_ACCOUNT_EMAIL \
              --member="PRINCIPAL" \
              --role="roles/iam.serviceAccountUser"
          

    Replace the following:

    • SERVICE_ACCOUNT_EMAIL: the service account email address you are using as the service identity, such as:
      • The Compute Engine default service account: PROJECT_NUMBER-compute@developer.gserviceaccount.com
      • A service account that you created: SERVICE_ACCOUNT_NAME@PROJECT_ID.iam.gserviceaccount.com
    • PRINCIPAL: the user identifier. This is typically the email address for a Google Account.

Deploy worker pool

To deploy the sample worker pool container, follow these steps:

  1. In the Google Cloud console, go to Cloud Run:

    Go to Cloud Run

  2. Select Worker pools from the menu, and click Deploy container to display the Create worker pools form.

  3. Click Test with a sample container.

  4. Click Create to deploy the image to Cloud Run. Wait for the deployment to finish.

  5. Click the Logs tab to view the logs written by the worker pool. The worker pool continually writes the log message Cloud Run Worker Pool instance is running!.

Clean up

The sample worker pool continually writes logs. So, to stop it, you'll need to delete the worker pool.

To delete a worker pool,

  1. In the Google Cloud console, go to Cloud Run:

    Go to Cloud Run

  2. Select Worker pools from the menu, and select the worker pool you want to delete.

  3. Click Delete.

What's next

For more information on worker pools, see: