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
- 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.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Verify that billing is enabled for your Google Cloud project.
-
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
-
In the Google Cloud console, go to the IAM page.
Go to IAM - Select the project.
-
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.
- 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
-
In the Google Cloud console, go to the IAM page.
Go to IAM - Select the project.
- Click Grant access.
-
In the New principals field, enter your user identifier. This is typically the email address for a Google Account.
- In the Select a role list, select a role.
- To grant additional roles, click Add another role and add each additional role.
- Click Save.
-
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Verify that billing is enabled for your Google Cloud project.
-
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
-
In the Google Cloud console, go to the IAM page.
Go to IAM - Select the project.
-
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.
- 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
-
In the Google Cloud console, go to the IAM page.
Go to IAM - Select the project.
- Click Grant access.
-
In the New principals field, enter your user identifier. This is typically the email address for a Google Account.
- In the Select a role list, select a role.
- To grant additional roles, click Add another role and add each additional role.
- Click Save.
-
-
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
- The Compute Engine default service account:
- PRINCIPAL: the user identifier. This is typically the email address for a Google Account.
- SERVICE_ACCOUNT_EMAIL: the service account email address
you are using as the service identity, such as:
Deploy worker pool
To deploy the sample worker pool container, follow these steps:
In the Google Cloud console, go to Cloud Run:
Select Worker pools from the menu, and click Deploy container to display the Create worker pools form.
Click Test with a sample container.
Click Create to deploy the image to Cloud Run. Wait for the deployment to finish.
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,
In the Google Cloud console, go to Cloud Run:
Select Worker pools from the menu, and select the worker pool you want to delete.
Click Delete.
What's next
For more information on worker pools, see: