クイックスタート: サンプル ワーカープールを Cloud Run にデプロイする

このページでは、サンプル ワーカープール コンテナをデプロイする方法について説明します。デプロイ後、ワーカープールはログ メッセージを継続的に書き込みます。

始める前に

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

  4. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  5. Make sure that billing is enabled for your Google Cloud project.

  6. Cloud Run Admin API を有効にします。
    Cloud Run Admin API を有効にする
  7. gcloud CLI をインストールして初期化します
  8. コンポーネントを更新します。
    gcloud components update

ワーカープールをデプロイする

サンプル ワーカープール コンテナをデプロイする手順は次のとおりです。

  1. In the Google Cloud console, activate Cloud Shell.

    Activate Cloud Shell

    At the bottom of the Google Cloud console, a Cloud Shell session starts and displays a command-line prompt. Cloud Shell is a shell environment with the Google Cloud CLI already installed and with values already set for your current project. It can take a few seconds for the session to initialize.

  2. 次のコマンドを実行します。

    gcloud beta run worker-pools deploy example-worker-pool
      --image us-docker.pkg.dev/cloudrun/container/worker-pool:latest
      --region europe-west1
    ワーカープールには任意の名前またはリージョンを使用できます。このクイックスタートでは、名前 example-worker-pool とリージョン europe-west1 を使用していることを前提としています。

  3. デプロイが正常に完了すると、Cloud Run に次のようなメッセージが表示されます。

    Worker pool [my-example-worker-pool] revision [my-example-worker-pool-REVISION] has been deployed

  4. ワーカープールによって書き込まれたログを表示します。

    1. Google Cloud コンソールで、[Cloud Run] ページに移動します。

      Cloud Run に移動

    2. [ワーカープール] をクリックします。

    3. ワーカープールのリストでワーカープールをクリックします。

    4. [ログ] タブをクリックして、このワーカープールのすべてのリビジョンのコンテナログを取得します。ワーカープールは、ログ メッセージ Cloud Run Worker Pool instance is running! を継続的に書き込みます。

クリーンアップ

サンプル ワーカープールはログを継続的に書き込みます。そのため、停止するにはワーカープールを削除する必要があります。

ワーカープールを削除するには、次のコマンドを使用します。

gcloud beta run worker-pools delete my-example-workerpool 
--region europe-west1

デプロイ時に別の名前を使用した場合は、my-example-workerpool をワーカープールの名前に置き換えます。デプロイ時に別のリージョンを使用した場合は、europe-west1 をリージョンに置き換えます。

次のステップ

ワーカープールの詳細については、以下をご覧ください。