クイックスタート: サンプル ワーカープールを 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 に移動 - プロジェクトを選択します。
- [ アクセスを許可] をクリックします。
-
[新しいプリンシパル] フィールドに、ユーザー ID を入力します。 これは通常、Google アカウントのメールアドレスです。
- [ロールを選択] リストでロールを選択します。
- 追加のロールを付与するには、 [別のロールを追加] をクリックして各ロールを追加します。
- [保存] をクリックします。
-
-
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 に移動 - プロジェクトを選択します。
- [ アクセスを許可] をクリックします。
-
[新しいプリンシパル] フィールドに、ユーザー ID を入力します。 これは通常、Google アカウントのメールアドレスです。
- [ロールを選択] リストでロールを選択します。
- 追加のロールを付与するには、 [別のロールを追加] をクリックして各ロールを追加します。
- [保存] をクリックします。
-
-
サービス ID にサービス アカウント ユーザーのロールが付与されていることを確認します。デフォルトでは、サービス ID は Compute Engine のデフォルトのサービス アカウントです。
ロールを付与する
サービス ID リソースに対するアクセス権を付与するには、
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: サービス ID として使用しているサービス アカウントのメールアドレス。たとえば次のようなものです。
- Compute Engine のデフォルトのサービス アカウント:
PROJECT_NUMBER-compute@developer.gserviceaccount.com
- 作成したサービス アカウント:
SERVICE_ACCOUNT_NAME@PROJECT_ID.iam.gserviceaccount.com
- Compute Engine のデフォルトのサービス アカウント:
- PRINCIPAL: ユーザー ID。通常は、Google アカウントのメールアドレスです。
- SERVICE_ACCOUNT_EMAIL: サービス ID として使用しているサービス アカウントのメールアドレス。たとえば次のようなものです。
- Cloud Run の料金を確認するか、料金計算ツールで費用を見積もります。
Google Cloud コンソールで Cloud Run に移動します。
メニューから [ワーカープール] を選択し、[コンテナをデプロイ] をクリックして、[ワーカープールの作成] フォームを表示します。
[サンプル コンテナでテスト] をクリックします。
[作成] をクリックしてイメージを Cloud Run にデプロイし、デプロイの完了を待ちます。
[ログ] タブをクリックして、ワーカープールによって書き込まれたログを表示します。ワーカープールは、ログメッセージ
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 リソースを解放する手順は次のとおりです。
次のステップ
ワーカープールの詳細については、以下をご覧ください。