快速入门:将示例工作器池部署到 Cloud Run
本页面介绍了如何部署示例工作器池容器。部署后,工作器池会持续写入日志消息。
准备工作
- 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.
前往 IAM - 选择项目。
- 点击 授予访问权限。
-
在新的主账号字段中,输入您的用户标识符。 这通常是 Google 账号的电子邮件地址。
- 在选择角色列表中,选择一个角色。
- 如需授予其他角色,请点击 添加其他角色,然后添加其他各个角色。
- 点击 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.
前往 IAM - 选择项目。
- 点击 授予访问权限。
-
在新的主账号字段中,输入您的用户标识符。 这通常是 Google 账号的电子邮件地址。
- 在选择角色列表中,选择一个角色。
- 如需授予其他角色,请点击 添加其他角色,然后添加其他各个角色。
- 点击 Save(保存)。
-
-
确保您已向服务身份授予 Service Account User 角色。默认情况下,服务身份是 Compute Engine 默认服务账号。
授予角色
如需授予服务身份资源的访问权限,请使用
gcloud iam service-accounts add-iam-policy-binding
命令,并将突出显示的变量替换为适当的值:gcloud iam service-accounts add-iam-policy-binding SERVICE_ACCOUNT_EMAIL \ --member="PRINCIPAL" \ --role="roles/iam.serviceAccountUser"
替换以下内容:
- SERVICE_ACCOUNT_EMAIL:您用作服务身份的服务账号邮箱,例如:
- Compute Engine 默认服务账号:
PROJECT_NUMBER-compute@developer.gserviceaccount.com
- 您创建的服务账号:
SERVICE_ACCOUNT_NAME@PROJECT_ID.iam.gserviceaccount.com
- Compute Engine 默认服务账号:
- PRINCIPAL:用户标识符。这通常是 Google 账号的邮箱。
- SERVICE_ACCOUNT_EMAIL:您用作服务身份的服务账号邮箱,例如:
在 Google Cloud 控制台中,前往 Cloud Run:
从菜单中选择工作器池,然后点击部署容器以显示创建工作器池表单。
点击使用示例容器进行测试。
点击创建以将映像部署到 Cloud Run,然后等待部署完成。
点击日志标签页以查看工作器池写入的日志。工作器池会持续写入日志消息
Cloud Run Worker Pool instance is running!
。在 Google Cloud 控制台中,前往 Cloud Run:
从菜单中选择工作器池,然后选择要删除的工作器池。
点击删除。
部署工作器池
如需部署示例工作器池容器,请按以下步骤操作:
清理
示例工作器池会持续写入日志。因此,如需停止工作器池,您需要将其删除。如需删除工作器池,请执行以下操作:
后续步骤
如需详细了解工作器池,请参阅: