為 Gemini Enterprise Agent Platform 資源設定 Private Service Connect 介面

本指南說明如何為 Gemini Enterprise Agent Platform 資源設定 Private Service Connect 介面。

您可以為 Gemini Enterprise Agent Platform 中的特定資源設定 Private Service Connect 介面連線,包括:

與虛擬私有雲對接連線不同,Private Service Connect 介面連線具有傳遞性。這樣一來,用戶虛擬私有雲網路中所需的 IP 位址數量就會減少。這樣一來,您就能更靈活地連線至 Cloud de Confiance by S3NS 專案和地端部署中的其他虛擬私有雲網路。

本指南適用於熟悉 Cloud de Confiance by S3NS 網路概念的網路管理員。

目標

本指南涵蓋下列工作:

  • 設定用戶虛擬私有雲 網路、子網路和網路連結。
  • 在 Cloud de Confiance by S3NS 網路主機專案中新增防火牆規則。
  • 建立 Agent Platform 資源,並指定網路連結,以便使用 Private Service Connect 介面。

事前準備

按照下列操作說明建立或選取 Cloud de Confiance 專案 ,並設定專案,以便搭配 Gemini Enterprise Agent Platform 和 Private Service Connect 使用。

  1. In the Cloud de Confiance console, on the project selector page, select or create a Cloud de Confiance 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 Cloud de Confiance project.

  3. Enable the Gemini Enterprise Agent Platform, Compute Engine, and Cloud Storage 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. Install the Google Cloud CLI.

  5. Configure the gcloud CLI to use your federated identity.

    For more information, see Sign in to the gcloud CLI with your federated identity.

  6. To initialize the gcloud CLI, run the following command:

    gcloud init
  7. 初始化 gcloud CLI 後,請更新 gcloud CLI 並安裝必要元件:

    gcloud components update
    gcloud components install beta
  8. 如果您不是專案擁有者,且不具備專案 IAM 管理員 (roles/resourcemanager.projectIamAdmin) 角色,請要求擁有者授予您Compute 網路管理員 (roles/compute.networkAdmin) 角色,以便管理網路資源。如果您只在現有虛擬私有雲網路中建立網路連結,可以改用包含 compute.networkAttachments.create 權限的自訂角色。
  9. 將必要角色指派給 AI Platform 服務代理。如要瞭解在不同情境下應授予哪些角色,請參閱本文的「Gemini Enterprise Agent Platform 服務代理必要角色」一節。

設定虛擬私有雲網路和子網路

如果沒有現有網路,請按照設定步驟建立新的虛擬私有雲網路。

  1. 建立虛擬私有雲網路:

    gcloud compute networks create NETWORK \
        --subnet-mode=custom
    

    將 NETWORK 替換為虛擬私有雲網路的名稱。

  2. 建立子網路:

    gcloud compute networks subnets create SUBNET_NAME \
        --network=NETWORK \
        --range=PRIMARY_RANGE \
        --region=REGION
    

    更改下列內容:

    • SUBNET_NAME:子網路名稱。
    • PRIMARY_RANGE:新子網路的主要 IPv4 範圍,採用 CIDR 標記法。

      以下是 Agent Platform 的 IP 規定和限制:

      • Agent Platform 會建議 /28 子網路。
      • 網路連結的子網路支援 RFC 1918 和非 RFC 1918 位址,但 100.64.0.0/20 和 240.0.0.0/4 子網路除外。
      • Agent Platform 只能連線至可從指定網路路由傳輸的 RFC 1918 IP 位址範圍。
      • Agent Platform 無法連上私用公開 IP 位址或下列非 RFC 1918 範圍:

        • 100.64.0.0/20
        • 192.0.0.0/24
        • 192.0.2.0/24
        • 198.18.0.0/15
        • 198.51.100.0/24
        • 203.0.113.0/24
        • 240.0.0.0/4

      詳情請參閱「IPv4 子網路範圍」。

    • REGION:建立新子網路的 Cloud de Confiance 區域。

建立網路連結

在 Shared VPC 部署作業中,請在主專案中建立用於網路連結的子網路,然後在服務專案中建立 Private Service Connect 網路連結。

以下範例說明如何建立自動接受連線的網路連結。

   gcloud compute network-attachments create NETWORK_ATTACHMENT_NAME \
       --region=REGION \
       --connection-preference=ACCEPT_AUTOMATIC \
       --subnets=SUBNET_NAME

將 NETWORK_ATTACHMENT_NAME 替換為網路連結的名稱。

如果網路連結是在服務專案以外的專案中建立,呼叫 Gemini Enterprise 時,必須傳遞完整的網路連結路徑。

Gemini Enterprise Agent Platform 服務代理人必要角色

Gemini Enterprise Agent Platform 服務代理 (AI 平台服務代理) 需要特定 IAM 角色,才能管理網路資源及建立 Private Service Connect 介面連線。

視網路設定而定,將下列角色授予服務代理 (service-PROJECT_NUMBER@gcp-sa-aiplatform.s3ns-system.iam.gserviceaccount.com):

  1. Compute 網路管理員 (roles/compute.networkAdmin)

    在您建立網路連結的專案中,必須將 roles/compute.networkAdmin 角色授予服務代理。如果不想授予 roles/compute.networkAdmin 角色,可以建立具備下列權限的自訂角色,並授予服務代理:

    • compute.networkAttachments.get
    • compute.networkAttachments.update
    • compute.regionOperations.get
  2. Compute 網路使用者 (roles/compute.networkUser)

    如果您使用共用虛擬私有雲,並在服務專案中建立網路連結,請在虛擬私有雲主專案中,將 roles/compute.networkUser 角色授予服務代理程式 (位於服務專案中)。

  3. DNS 對接 (roles/dns.peer)

    如要讓 Agent Platform Managed Training 或 Agent Runtime 等資源解析私人 DNS 記錄,請將 roles/dns.peer 角色授予服務代理。請在您使用服務的專案中授予這個角色。如果使用 Shared VPC,您也必須將 roles/dns.peer 角色授予 VPC 主專案中的服務代理。

設定防火牆規則

系統會套用用戶端虛擬私有雲中的輸入防火牆規則,以便從運算和地端部署端點,與 Private Service Connect 介面網路連結子網路通訊。

您可以視需要設定防火牆規則。不過,建議您按照下列範例設定常見的防火牆規則。

  1. 建立防火牆規則,允許透過 TCP 通訊埠 22 進行 SSH 存取:

    gcloud compute firewall-rules create NETWORK-firewall1 \
        --network NETWORK \
        --allow tcp:22
    
  2. 建立防火牆規則,允許 TCP 通訊埠 443 的 HTTPS 流量:

    gcloud compute firewall-rules create NETWORK-firewall2 \
        --network NETWORK \
        --allow tcp:443
    
  3. 建立允許 ICMP 流量 (例如 ping 要求) 的防火牆規則:

    gcloud compute firewall-rules create NETWORK-firewall3 \
        --network NETWORK \
        --allow icmp
    

設定私人 DNS 對接

如要讓 Agent Platform Managed Training 作業或設定 Private Service Connect 介面的 Agent Runtime 代理程式,解析客戶管理的 Cloud DNS 區域中的私人 DNS 記錄,您可以在設定或部署資源時指定網路連結,並建立私人 DNS 對接。

如要設定 DNS 對接,請在 psc_interface_config 下方的 dns_peering_configs 欄位中指定目標網路和網域字尾:

  • dns_peering_configs:DNS 對接設定清單:
    • domain:私有 Cloud DNS 區域的 DNS 名稱。
    • target_project:託管虛擬私有雲網路的專案。可以與建立網路連結的專案不同。
    • target_network:建立 DNS 對接的目標專案中的虛擬私有雲網路名稱。

舉例來說,在 Python 中建立資源時,您可以按照下列方式設定私人 DNS 對接:

psc_interface_config = {
    "network_attachment": "NETWORK_ATTACHMENT",
    "dns_peering_configs": [
        {
            "domain": "DOMAIN_SUFFIX",
            "target_project": "TARGET_PROJECT",
            "target_network": "TARGET_NETWORK",
        },
    ],
}

更改下列內容:

  • NETWORK_ATTACHMENT:網路連結的名稱或完整路徑。例如,projects/SERVICE_PROJECT/regions/REGION/networkAttachments/NETWORK_ATTACHMENT_NAME。如果您在與使用 Agent Platform 的服務專案不同的專案中建立網路連結,則必須傳遞網路連結的完整路徑。
  • DOMAIN_SUFFIX:私有雲 Cloud DNS 區域的 DNS 名稱 (例如 example.com.)。
  • TARGET_PROJECT:託管虛擬私有雲網路的專案。可以與建立網路連結的專案不同。
  • TARGET_NETWORK:目標專案中建立 DNS 對接的虛擬私有雲網路名稱。

疑難排解

本節說明使用 Gemini Enterprise Agent Platform 設定 Private Service Connect 時,可能會遇到的一些常見問題。

使用 Shared VPC 設定 Agent Platform 時,請在您使用 Agent Platform 的服務專案中建立網路連結。這種做法有助於避免出現特定錯誤訊息,例如:

_Please make sure that the Agent Platform API is enabled for the
project_, by ensuring the
necessary permissions and APIs are enabled in the correct project.

後續步驟

  • 瞭解如何使用 Ray on Vertex AI 的 Private Service Connect 介面輸出。
  • 瞭解如何使用 Private Service Connect 介面輸出,進行自訂訓練。
  • 瞭解如何使用 Agent Platform Pipelines 的 Private Service Connect 介面輸出。
  • 瞭解如何使用 Private Service Connect 介面輸出,適用於Agent Runtime