App Lifecycle Manager を使用してアプリケーションをデプロイする

App Lifecycle Manager を使用すると、マルチコンポーネント アプリケーションのデプロイとライフサイクル管理を自動化できます。これにより、 Google Cloud全体で一貫した環境をプロビジョニングできます。このクイックスタートでは、Application Design Center で Cloud Run と Cloud Storage を使用して複合アプリケーション テンプレートをモデル化し、ライブユニットをプロビジョニングします。

始める前に

  1. 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

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

  3. Enable the App Lifecycle Manager, Artifact Registry, Cloud Build, Cloud Run, Cloud Storage, Developer Connect, Infrastructure Manager, App Design Center, App Hub, Resource Manager, Identity and Access Management, Cloud Asset Inventory, Cloud Monitoring, Cloud Logging, and Service Health APIs, if any are not already enabled.

    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

  4. Create a service account:

    1. Ensure that you have the Create Service Accounts IAM role (roles/iam.serviceAccountCreator) and the Project IAM Admin role (roles/resourcemanager.projectIamAdmin). Learn how to grant roles.
    2. In the Google Cloud console, go to the Create service account page.

      Go to Create service account
    3. Select your project.
    4. In the Service account name field, enter a name. The Google Cloud console fills in the Service account ID field based on this name.

      In the Service account description field, enter a description. For example, Service account for quickstart.

    5. Click Create and continue.
    6. Grant the Project > Owner role to the service account.

      To grant the role, find the Select a role list, then select Project > Owner.

    7. Click Continue.
    8. Click Done to finish creating the service account.

  5. App Lifecycle Manager サービス アカウントに必要な権限を付与します。
    1. Google Cloud コンソールで、[App Lifecycle Manager] > [概要] > [使ってみる] に移動します。

      [App Lifecycle Manager の利用を開始しましょう] に移動

    2. 「App Lifecycle Manager アカウントに必要な権限が付与されていません」というメッセージのバナーが表示された場合は、[権限を付与] をクリックします。

複合テンプレートを使用してサービスをモデル化する

App Lifecycle Manager と Application Design Center を使用して、Cloud Run サービスを Cloud Storage バケットに接続する複合テンプレート(run-storage-quickstart)をモデル化します。

SaaS サービスを構成する

  1. Google Cloud コンソールで、[App Lifecycle Manager] > [SaaS offering] に移動します。

    [SaaS サービス] に移動

  2. [作成] をクリックします。

  3. [SaaS サービス名] フィールドに「run-storage-quickstart-offering」と入力します。

  4. [リージョン] リストで、次のリージョンを選択し、[OK] をクリックします。

    • us-central1
    • us-east1
    • us-east5
  5. [作成] をクリックします。run-storage-quickstart-offering の作成には数分かかります。

    SaaS サービスが作成されると、[SaaS サービスの詳細] ページが開きます。

複合テンプレートを作成する

  1. [SaaS サービスの詳細] ページで、[新しいテンプレートを作成] をクリックします。
  2. [新しい複合テンプレートの作成] ページで、テンプレートを構成します。

    1. [テンプレート ID] フィールドに「run-storage-quickstart」と入力します。
    2. [テンプレートを作成] をクリックします。

      App Lifecycle Manager が複合テンプレートの作成を完了すると、その詳細が [SaaS サービスの詳細] ページの [接続されたアプリケーション テンプレート] セクションに表示されます。

  3. [接続されたアプリケーション テンプレート] セクションで、[テンプレートを管理] をクリックし、[キャンバスで構成] をクリックします。

    App Design Center が Google Cloud コンソールで開きます。

  4. [コンポーネント] 領域で、次のコンポーネントをデザイン キャンバスに追加します。

    1. [Cloud Run(サービス)] をクリックして、cloud-run-1 コンポーネントをキャンバスに追加します。
    2. [Cloud Storage] をクリックして、cloud-storage-1 コンポーネントをキャンバスに追加します。
  5. キャンバスで、cloud-run-1 コンポーネントから cloud-storage-1 コンポーネントにドラッグして接続を作成します。

    コンポーネントを接続すると、Cloud Run サービス アカウントが roles/storage.objectAdmin ロールを持つ Cloud Storage バケットの IAM バインディングに渡されます。

  6. キャンバスで [cloud-run-1] コンポーネントをクリックして、[構成] パネルを開きます。

    1. [コンテナ] 領域で、[コンテナ 1] を開きます。
    2. [コンテナ イメージ] フィールドに、公開サンプル コンテナ イメージ us-docker.pkg.dev/cloudrun/container/hello:latest を入力します。
    3. [保存] をクリックします。
  7. [続行] > [App Lifecycle Manager を使用して大規模にデプロイ] をクリックします。

    Google Cloud コンソールで App Lifecycle Manager が開きます。

  8. [接続されたアプリケーション テンプレート] セクションで、[テンプレート リビジョンを更新] をクリックします。

  9. [テンプレート リビジョンの更新] ページで、[リビジョン] リストから r-2 を選択し、[更新] をクリックします。

    [接続済みのアプリケーション テンプレート] セクションに、[アプリケーション テンプレートをインポートしています] と表示されます。インポートが完了すると、[Unit kinds] タブに、生成された u-native-components ユニットの種類が表示されます。

App Lifecycle Manager を使用してアプリケーションをプロビジョニングする

  1. run-storage-quickstart-offering の [SaaS サービスの詳細] ページで、[プロビジョニング] をクリックします。

    [プロビジョニング] ページが開きます。

  2. [プロビジョニング] ページで、[リージョン] リストから us-central1 を選択し、[追加] をクリックします。

  3. [プロビジョニングするユニットの追加] パネルで、ユニットを構成します。

    1. [Unit name] フィールドに「run-storage-quickstart-unit-1」と入力します。
    2. [Unit kind] リストで、u-native-components 単位の種類を選択します。
    3. [リリース] リストで、テンプレート リビジョン用に生成されたリリースを選択します。
    4. [サービス アカウント] リストで、始める前にセクションで作成したアクチュエーション サービス アカウントを選択します。
  4. [テナント プロジェクト変数を追加] をクリックし、リソースのプロビジョニングに使用するプロジェクトを選択します。

  5. [その他の入力変数] 領域で、[入力変数を追加] をクリックし、次のコンポーネント入力変数の値を入力します。

    • 名前: cloud-run-1_project_id、変数タイプ: String、変数値: プロジェクト ID
    • 名前: cloud-run-1_location、変数タイプ: String、変数値: us-central1
    • 名前: cloud-run-1_service_name、変数タイプ: String、変数値: quickstart-web
    • 名前: cloud-storage-1_project_id、変数タイプ: String、変数値: プロジェクト ID
    • 名前: cloud-storage-1_location、変数タイプ: String、変数値: us-central1
    • 名前: cloud-storage-1_name、変数タイプ: String、変数値: グローバルに一意のバケット名(PROJECT_ID-quickstart-bkt など)
  6. [追加] をクリックします。run-storage-quickstart-unit-1 ユニットが [プロビジョニングするユニット] テーブルに表示されます。

  7. [プロビジョニング] をクリックして run-storage-quickstart-unit-1 をデプロイします。

    数分後に Cloud Run サービスと Cloud Storage がプロビジョニングされます。

  8. 他のリージョンで追加のユニットをプロビジョニングするには、[リージョン] リストからリージョンを選択し、[追加] をクリックします。

デプロイされたユニットを表示する

App Lifecycle Manager がユニットとそのリソースをプロビジョニングしたことを確認します。

  1. Google Cloud コンソールで、[App Lifecycle Manager] > [ユニット] ページに移動します。

    [ユニット] に移動

  2. run-storage-quickstart-unit-1 をクリックして、[ユニットの詳細] ページを開きます。

  3. [ユニットの詳細] ページで、[状態] フィールドを確認します。

    • 準備完了: Cloud Run サービスと Cloud Storage バケットがプロビジョニングされています。
    • プロビジョニング: デプロイ オペレーションが進行中です。

クリーンアップ

このページで使用したリソースについて、 Google Cloud アカウントに課金されないようにするには、次の手順を実施します。

プロジェクトを削除する

アプリケーション リソースを新しい Google Cloud プロジェクトにデプロイした後、そのプロジェクトが不要になった場合は、次の手順で削除します。

  1. Google Cloud コンソールで [リソースの管理] ページに移動します。

    [リソースの管理] に移動

  2. プロジェクト リストで、削除するプロジェクトを選択し、[削除] をクリックします。
  3. プロンプトでプロジェクト ID を入力し、[シャットダウン] をクリックします。

次のステップ