快速入門導覽課程:將範例工作站集區部署至 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.
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
(
roles/resourcemanager.projectCreator
), which contains theresourcemanager.projects.create
permission. Learn how to grant roles.
-
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 - 選取專案。
- 按一下 「授予存取權」。
-
在「New principals」(新增主體) 欄位中,輸入您的使用者 ID。 這通常是 Google 帳戶的電子郵件地址。
- 在「Select a role」(選取角色) 清單中,選取角色。
- 如要授予其他角色,請按一下 「新增其他角色」,然後新增每個其他角色。
- 按一下 [Save]。
-
-
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
(
roles/resourcemanager.projectCreator
), which contains theresourcemanager.projects.create
permission. Learn how to grant roles.
-
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 - 選取專案。
- 按一下 「授予存取權」。
-
在「New principals」(新增主體) 欄位中,輸入您的使用者 ID。 這通常是 Google 帳戶的電子郵件地址。
- 在「Select a role」(選取角色) 清單中,選取角色。
- 如要授予其他角色,請按一下 「新增其他角色」,然後新增每個其他角色。
- 按一下 [Save]。
-
-
請確認您已獲得服務身分的服務帳戶使用者角色。根據預設,服務身分是 Compute Engine 預設服務帳戶。
授予角色
如要授予服務身分資源的存取權,請使用
gcloud iam service-accounts add-iam-policy-binding
指令,並將醒目顯示的變數替換為適當的值:gcloud iam service-accounts add-iam-policy-binding SERVICE_ACCOUNT_EMAIL \ --member=user: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:使用者 ID。這通常是部署 Cloud Run 資源的 Google 帳戶電子郵件地址。
- SERVICE_ACCOUNT_EMAIL:您用來做為服務身分的服務帳戶電子郵件地址,例如:
- 查看 Cloud Run 定價,或使用 Pricing Calculator 估算費用。
前往 Google Cloud 控制台的 Cloud Run:
從選單中選取「工作站集區」,然後按一下「部署容器」,顯示「建立工作站集區」表單。
按一下「Test with a sample container」(使用範例容器進行測試)。
按一下「Create」(建立),將映像檔部署到 Cloud Run。等待部署作業完成。
按一下「Logs」(記錄) 分頁標籤,即可查看工作站集區寫入的記錄。 工作站集區會持續寫入記錄訊息
Cloud Run Worker Pool instance is running!
。前往 Google Cloud 控制台的 Cloud Run:
從選單中選取「工作站集區」,然後選取要刪除的工作站集區。
點選「刪除」。
- In the Google Cloud console, go to the Manage resources page.
- In the project list, select the project that you want to delete, and then click Delete.
- In the dialog, type the project ID, and then click Shut down to delete the project.
部署工作站集區
如要部署範例工作站集區容器,請按照下列步驟操作:
清除所用資源
如要避免系統向您的 Google Cloud 帳戶收取額外費用,請刪除您透過本快速入門導覽課程部署的所有資源。
刪除存放區
將容器映像檔儲存在 Artifact Registry 中可能會產生費用。如要刪除 Artifact Registry 存放區,請按照 Artifact Registry 說明文件中的「刪除存放區」一節所述步驟操作。
刪除工作站集區
範例工作站集區會持續寫入記錄。如要停止記錄,請按照下列任一方法刪除工作站集區:
刪除測試專案
刪除 Google Cloud 專案後,系統就會停止對該專案中的所有資源收取費用。如要釋出專案中的所有 Google Cloud 資源,請按照下列步驟操作:
後續步驟
如要進一步瞭解工作站集區,請參閱: