Cloud Deploy を使用してアプリを Cloud Run にデプロイする

このページでは、Cloud Deploy を使用して、hello という名前のサンプル アプリケーション イメージを連続する 2 つの Cloud Run サービス、2 つの Cloud Run ジョブ、または 2 つの Cloud Run ワーカープールに配信する方法を説明します。

このクイックスタートでは、以下の内容を行います。

  1. Skaffold 構成を作成する

  2. 2 つの Cloud Run サービス、2 つのジョブ、または 2 つのワーカープールの構成ファイルを作成します。

    これらのファイルによって、サービスまたはジョブを定義し、デプロイする(ビルド済みの)コンテナ イメージが指定されます。

  3. Cloud Deploy デリバリー パイプラインとデプロイ ターゲットを定義します。これらは、2 つのサービス、2 つのジョブ、または 2 つのワーカープールを指します。

  4. リリースを作成してデリバリー パイプラインをインスタンス化します。リリースは自動的に最初のターゲットにデプロイされます。

  5. リリースを 2 番目のターゲットにプロモートします。

  6. Google Cloud コンソールで両方のロールアウトを表示します。

始める前に

  1. Google Cloud アカウントにログインします。 Google Cloudを初めて使用する場合は、 アカウントを作成して、実際のシナリオでの Google プロダクトのパフォーマンスを評価してください。新規のお客様には、ワークロードの実行、テスト、デプロイができる無料クレジット $300 分を差し上げます。
  2. 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 role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  3. If you're using an existing project for this guide, verify that you have the permissions required to complete this guide. If you created a new project, then you already have the required permissions.

  4. Verify that billing is enabled for your Google Cloud project.

  5. Enable the Cloud Deploy, Cloud Build, Cloud Run, and Cloud Storage APIs.

    Roles required to enable APIs

    To enable APIs, you need the serviceusage.services.enable permission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.

    Enable the APIs

  6. Google Cloud CLI をインストールします。

  7. 外部 ID プロバイダ(IdP)を使用している場合は、まず連携 ID を使用して gcloud CLI にログインする必要があります。

  8. gcloud CLI を初期化するには、次のコマンドを実行します。

    gcloud init
  9. 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 role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  10. If you're using an existing project for this guide, verify that you have the permissions required to complete this guide. If you created a new project, then you already have the required permissions.

  11. Verify that billing is enabled for your Google Cloud project.

  12. Enable the Cloud Deploy, Cloud Build, Cloud Run, and Cloud Storage APIs.

    Roles required to enable APIs

    To enable APIs, you need the serviceusage.services.enable permission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.

    Enable the APIs

  13. Google Cloud CLI をインストールします。

  14. 外部 ID プロバイダ(IdP)を使用している場合は、まず連携 ID を使用して gcloud CLI にログインする必要があります。

  15. gcloud CLI を初期化するには、次のコマンドを実行します。

    gcloud init

必要なロール

Cloud Deploy オペレーションを実行して Cloud Run にデプロイするために必要な権限が Cloud Deploy サービス アカウントに付与されるように、プロジェクトに対する次の IAM ロールを Cloud Deploy サービス アカウントに付与するよう管理者に依頼してください。

ロールの付与については、プロジェクト、フォルダ、組織へのアクセス権の管理をご覧ください。

管理者は、カスタムロールや他の事前定義ロールを使用して、Cloud Deploy サービス アカウントに必要な権限を付与することもできます。