Google テンプレートをカスタマイズしてデプロイする

このクイックスタートでは、Google 提供のテンプレートをコピーし、その コンポーネントをカスタマイズして、テスト アプリケーションをデプロイします。このクイックスタートでは Cloud SQL を使用した生成 AI RAG テンプレートを使用しますが、 このドキュメントの手順は任意のテンプレートに適用できます。

次の図は、デザイン キャンバスでの Cloud SQL を使用した生成 AI RAG テンプレートのコンポーネントと接続を示しています。

デザイン キャンバスの生成 AI RAG アプリケーション。

始める前に

  1. アカウントにログインします。 Google Cloud を初めて使用する場合は、 アカウントを作成して、実際のシナリオで Google プロダクトのパフォーマンスを評価してください。 Google Cloud新規のお客様には、ワークロードの実行、テスト、デプロイができる無料クレジット $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. Verify 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.

    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

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

  6. プロジェクトで App Design Center を設定します

必要なロール

管理者に、次の表に記載されているロールの付与を依頼します。

タスク 必要なロール
テンプレートのコピー、設計、編集 App Design Center 管理者 (roles/designcenter.admin)、または
App Design Center ユーザー(roles/designcenter.user
アプリケーションと構成のデプロイ アプリケーション管理者(roles/designcenter.applicationAdmin)、 または
アプリケーション編集者 (roles/designcenter.applicationEditor
デプロイ中にサービス アカウントを作成する プロジェクトに対するサービス アカウントの作成 (roles/iam.serviceAccountCreator
サービス アカウントにプロジェクトへのアクセス権を付与する プロジェクトに対するプロジェクト IAM 管理者(roles/resourcemanager.projectIamAdmin

ロールの詳細については、 IAM を使用したアクセス制御をご覧ください。

環境を準備する

このクイックスタートを完了するには、次のいずれかを使用します。

  • コンソールのデザイン キャンバスを使用します。 Google Cloud
  • アカウントにログインします。 Google Cloud を初めて使用する場合は、 アカウントを作成して、実際のシナリオで Google プロダクトのパフォーマンスを評価してください。 Google Cloud新規のお客様には、ワークロードの実行、テスト、デプロイができる無料クレジット $300 分を差し上げます。
  • Google Cloud CLI をインストールします。

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

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

    gcloud init
  • Google Cloud CLI をインストールします。

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

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

    gcloud init

テンプレートをコピーしてアプリケーションのドラフトを作成する

Google テンプレートをコピーして、アプリケーションのドラフトを構成します。

デザイナー キャンバス

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

    [Google テンプレート] に移動

  2. [Cloud SQL を使用した生成 AI RAG] テンプレート カードで [プレビューとカスタマイズ] をクリックします。

    テンプレートがデザイン キャンバスで開きます。

  3. [複製してカスタマイズ] をクリックします。

  4. [新しいテンプレートを作成] ダイアログで、次の詳細を入力します。

    1. [テンプレート ID] フィールドに「quickstart-custom-gen-ai-rag」と入力します。

    2. [テンプレート名] フィールドに「Quickstart custom Generative AI RAG」と入力します。

    3. [説明] フィールドに A custom template copied from the Generative AI RAG with Cloud SQL template. と入力します。

    4. [テンプレートを作成] をクリックします。

    テンプレートがスペースにコピーされ、デザイン キャンバスに表示されます。

  5. デザイン キャンバスで、[アプリの設定] をクリックします。

  6. [新しいアプリケーションを作成] をクリックして、次の詳細を入力します。

    1. [名前] フィールドに「quickstart-custom-gen-ai-rag-test」と入力します。

    2. [表示名] フィールドに「Quickstart custom Generative AI RAG test」と入力します。

    3. [リージョン] リストで us-central1 (Iowa) を選択します。

    4. [環境] リストで [Test] を選択します。

    5. [重要度] リストで Low を選択します。

  7. [アプリケーションを作成] をクリックします。

    アプリケーションのドラフトが作成されます。

gcloud CLI

  1. Google カタログで共有テンプレートをフィルタして、gen-ai-rag-with-sql テンプレートのリビジョン URI を見つけます。

    gcloud design-center spaces shared-templates list \
      --google-catalog \
      --location=LOCATION \
      --filter="displayName:gen-ai-rag-cloud-sql"
    

    次のように置き換えます。

    • LOCATION: スペースのロケーション。 例: us-central1

    出力からリビジョン URI を特定します。

  2. そのテンプレート リビジョンからアプリケーションのドラフトを作成します。

    gcloud design-center spaces applications create quickstart-custom-gen-ai-rag-test \
      --space=SPACE \
      --location=LOCATION \
      --project=PROJECT \
      --source-shared-template-revision-uri=SHARED_TEMPLATE_REVISION_URI \
      --display-name="Quickstart custom Generative AI RAG test" \
      --environment-type=test \
      --criticality-type=low \
      --scope-type=regional \
      --deployment-region=LOCATION
    

    次のように置き換えます。

    • SPACE: スペース ID。例: default-space
    • PROJECT: プロジェクト ID。
    • SHARED_TEMPLATE_REVISION_URI: テンプレートのリビジョン URI。例: projects/gcpdesigncenter/locations/us-central1/spaces/googlespace/sharedTemplates/f8ddfbd3-6393-4a1e-942c-aaa7292fa30c/revisions/r-28

コンポーネントを構成する

アプリケーションのドラフトで必要なコンポーネント パラメータを構成します。コンポーネント パラメータの詳細については、サポート対象のリソースをご覧ください。

デザイナー キャンバス

  1. デザイン キャンバスで [frontend-service] をクリックし、[構成] 領域で次の操作を行います。

    1. [サービス名] フィールドに「custom-rag-frontend」と入力します。

    2. [保存] をクリックします。

  2. デザイン キャンバスで [retrieval-service] をクリックし、[構成] 領域で次の操作を行います。

    1. [サービス名] フィールドに「custom-retrieval-service」と入力します。

    2. [保存] をクリックします。

  3. デザイン キャンバスで [database-postgresql] をクリックし、[構成] 領域で次の操作を行います。

    1. [名前] フィールドに「custom-rag-database」と入力します。

    2. [保存] をクリックします。

  4. デザイン キャンバスで [vertex-ai] をクリックし、[構成] 領域で次の操作を行います。

    1. [プロジェクト ID] リストで、プロジェクトが選択されていることを確認します。

    2. [保存] をクリックします。

  5. デザイン キャンバスで [secret-manager] をクリックし、[構成] 領域で次の操作を行います。

    1. [名前] フィールドに「db-ai-secret」と入力します。

    2. [保存] をクリックします。

キャンバスの各コンポーネントに緑色のチェックマークが表示され、必要なパラメータがすべて構成されていることが示されます。

gcloud CLI

  1. アプリケーションを記述して、コンポーネント パラメータを特定します。

    gcloud design-center spaces applications describe quickstart-custom-gen-ai-rag-test \
      --space=SPACE \
      --location=LOCATION \
      --project=PROJECT \
      --format='yaml(name,componentParameters)'
    

    出力には、各コンポーネントのパラメータが表示されます。

  2. コンポーネント URI のリストを取得します。

    gcloud design-center spaces applications describe quickstart-custom-gen-ai-rag-test \
      --space=SPACE \
      --location=LOCATION \
      --project=PROJECT \
      --format='value(serializedApplicationTemplate.components.uri)'
    
  3. 作業ディレクトリに構成 JSON ファイルを作成します。

    1. custom-frontend.json を作成します。

      {
         "component": "FRONTEND_COMPONENT_URI",
         "parameters": [
            {
               "key": "service_name",
               "value": "custom-rag-frontend"
            },
            {
               "key": "PROJECT",
               "value": "PROJECT"
            },
            {
               "key": "location",
               "value": "LOCATION"
            }
         ]
      }
      
    2. custom-retrieval.json を作成します。

      {
         "component": "RETRIEVAL_COMPONENT_URI",
         "parameters": [
            {
               "key": "service_name",
               "value": "custom-retrieval-service"
            },
            {
               "key": "project_id",
               "value": "PROJECT"
            },
            {
               "key": "location",
               "value": "LOCATION"
            }
         ]
      }
      
    3. custom-database.json を作成します。

      {
         "component": "DATABASE_COMPONENT_URI",
         "parameters": [
            {
               "key": "name",
               "value": "custom-rag-database"
            },
            {
               "key": "project_id",
               "value": "PROJECT"
            },
            {
               "key": "database_version",
               "value": "POSTGRES_15"
            },
            {
               "key": "region",
               "value": "us-central1"
            },
            {
               "key": "zone",
               "value": "us-central1-a"
            }
         ]
      }
      
    4. custom-secmanager.json を作成します。

      {
      "component": "SECRET_MANAGER_COMPONENT_URI",
      "parameters": [
         {
            "key": "name",
            "value": "db-ai-secret"
         },
         {
            "key": "project_id",
            "value": "PROJECT"
         }
      ]
      }
      
    5. custom-vertex.json を作成します。

      {
      "component": "VERTEX_AI_COMPONENT_URI",
      "parameters": [
         {
            "key": "project_id",
            "value": "PROJECT"
         }
      ]
      }
      

    次のように置き換えます。

    • FRONTEND_COMPONENT_URI: フロントエンド コンポーネントの URI。例: projects/gcpdesigncenter/locations/us-central1/spaces/googlespace/applicationTemplates/gen-ai-rag-cloud-sql/components/frontend-service
    • RETRIEVAL_COMPONENT_URI: 取得コンポーネントの URI。例: projects/gcpdesigncenter/locations/us-central1/spaces/googlespace/applicationTemplates/gen-ai-rag-cloud-sql/components/retrieval-service
    • DATABASE_COMPONENT_URI: データベース コンポーネントの URI。例: projects/gcpdesigncenter/locations/us-central1/spaces/googlespace/applicationTemplates/gen-ai-rag-cloud-sql/components/database-postgresql
    • SECRET_MANAGER_COMPONENT_URI: Secret Manager コンポーネントの URI。例: projects/gcpdesigncenter/locations/us-central1/spaces/googlespace/applicationTemplates/gen-ai-rag-cloud-sql/components/secret-manager
    • VERTEX_AI_COMPONENT_URI: Vertex AI コンポーネントの URI。例: projects/gcpdesigncenter/locations/us-central1/spaces/googlespace/applicationTemplates/gen-ai-rag-cloud-sql/components/vertex-ai
    • PROJECT: プロジェクト ID。
  4. JSON パラメータ ファイルを使用して、アプリケーション構成を更新します。

    gcloud design-center spaces applications update quickstart-custom-gen-ai-rag-test \
      --space=SPACE \
      --location=LOCATION \
      --project=PROJECT \
      --component-parameters=./custom-frontend.json \
      --component-parameters=./custom-retrieval.json \
      --component-parameters=./custom-database.json \
      --component-parameters=./custom-secmanager.json \
      --component-parameters=./custom-vertex.json
    

アプリケーションをデプロイする

構成したアプリケーションをデプロイします。

デザイナー キャンバス

  1. [デプロイ] をクリックします。

  2. [サービス アカウントを選択] 領域で、次の操作を行います。

    1. [新しいサービス アカウントを作成] を選択します。

    2. [続行] をクリックします。

  3. [デプロイ] をクリックします。

    数分後、アプリケーションがデプロイされ、リソースが作成されます。

gcloud CLI

  1. デプロイをプレビューし、プレビュー サービス アカウントを自動的に作成します。

    gcloud design-center spaces applications preview quickstart-custom-gen-ai-rag-test \
      --space=SPACE \
      --location=LOCATION \
      --project=PROJECT \
      --create-sa
    
  2. アプリケーションをデプロイし、デプロイ サービス アカウントを自動的に作成します。

    gcloud design-center spaces applications deploy quickstart-custom-gen-ai-rag-test \
      --space=SPACE \
      --location=LOCATION \
      --project=PROJECT \
      --create-sa \
      --async
    

    オペレーション ID をコピーします。

  3. デプロイのステータスを追跡します。

    gcloud design-center operations describe operation-OPERATION_ID \
      --space=SPACE \
      --location=LOCATION \
      --project=PROJECT
    

    次のように置き換えます。

    • OPERATION_ID: オペレーション ID。

省略可: デプロイをモニタリングする

アプリケーションをデプロイしたら、テレメトリーを表示してパフォーマンスをモニタリングできます。

  1. コンソールで、[アプリケーションのモニタリング] ページに移動します。 Google Cloud

    [アプリケーションのモニタリング] に移動

    検索バーを使用してこのページを検索する場合は、小見出しが [Monitoring] である結果を選択します。

  2. [名前] 列で、デプロイしたアプリケーションをクリックします。

    このページには、アプリケーションとそのサービスとワークロードのモニタリング情報が表示されます。

  3. 事前定義されたダッシュボードを確認します。詳細については、 Application Monitoring の概要をご覧ください。

クリーンアップ

このページで使用したリソースについて、アカウントに課金されないようにするには、リソースを含むプロジェクトを削除します。 Google Cloud Google Cloud

デプロイされたアプリケーションを削除する

デザイナー キャンバス

  1. ナビゲーション メニューで [アプリケーション] をクリックします。

    [アプリケーション] に移動

  2. [Quickstart custom Generative AI RAG test] をクリックします。

  3. [**アクション**] をクリックして、 [**アプリケーションを削除**] を選択します。

  4. [削除] フィールドに「quickstart-custom-gen-ai-rag-test」と入力します。

  5. [削除] をクリックします。

gcloud CLI

  1. CLI を使用してアプリケーションを削除します。

    gcloud design-center spaces applications delete quickstart-custom-gen-ai-rag-test \
      --space=SPACE \
      --location=LOCATION \
      --project=PROJECT
    

省略可: プロジェクトを削除する

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

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

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

次のステップ