為 Vertex AI 資源設定 Private Service Connect 介面

本指南說明如何為 Vertex AI 資源設定 Private Service Connect 介面

您可以為 Vertex AI 中的特定資源設定 Private Service Connect 介面連線,包括:

虛擬私有雲對等互連連線不同,Private Service Connect 介面連線可以具有遞移性,因此用戶虛擬私有雲網路中需要的 IP 位址較少。因此您可以更彈性地連線至 Google Cloud 專案和地端部署中的其他虛擬私有雲網路。

本指南適合熟悉 Google Cloud 網路概念的網路管理員。

目標

本指南涵蓋下列工作:

  • 設定生產者 VPC 網路、子網路和網路附件。
  • 在 Google Cloud 網路主專案中新增防火牆規則。
  • 建立 Vertex AI 資源,並指定要使用 Private Service Connect 介面的網路附件。

事前準備

按照下列操作說明建立或選取 Google Cloud 專案,並設定專案以搭配 Vertex AI 和 Private Service Connect 使用。

  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. Enable the Vertex AI, Compute Engine, and Cloud Storage APIs.

    Enable the APIs

  5. Install the Google Cloud CLI.

  6. If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

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

    gcloud init
  8. After initializing the gcloud CLI, update it and install the required components:

    gcloud components update
    gcloud components install beta
  9. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

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

  11. Enable the Vertex AI, Compute Engine, and Cloud Storage APIs.

    Enable the APIs

  12. Install the Google Cloud CLI.

  13. If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

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

    gcloud init
  15. After initializing the gcloud CLI, update it and install the required components:

    gcloud components update
    gcloud components install beta
  16. 如果您不是專案擁有者,且沒有專案 IAM 管理員 (roles/resourcemanager.projectIamAdmin) 角色,請要求擁有者授予您 Compute Network Admin (roles/compute.networkAdmin) 角色,其中包含管理網路資源所需的角色。
  17. 將網路主機 Google Cloud 專案的 Compute 網路管理員角色指派給您使用 Vertex AI Training 服務的專案的 AI Platform 服務代理人帳戶。
  18. 設定虛擬私有雲網路和子網路

    在本節中,您可以使用現有的虛擬私有雲網路,或按照設定步驟建立新的虛擬私有雲網路 (如果沒有現有網路)。

    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 標記法。詳情請參閱「IPv4 子網路範圍」。

        Vertex AI 需要 /28 子網路。

        Vertex AI 只能連線至可從指定 NETWORK 路由傳送的 RFC 1918 範圍。如需有效 RFC 1918 範圍的清單,請參閱「有效的 IPv4 範圍」。Vertex AI 無法連線至下列非 RFC 1918 範圍:

        • 100.64.0.0/10
        • 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
      • REGION:建立新子網路的 Google Cloud 區域。

    建立網路連結

    在共用虛擬私有雲部署作業中,請先在主專案中建立用於網路附件的子網路,然後在服務專案中建立 Private Service Connect 網路附件。

    以下範例說明如何建立網路附件,手動接受連線。

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

    NETWORK_ATTACHMENT_NAME 替換為網路附件的名稱。

    Vertex AI 服務代理所需的角色

    在建立網路附件的專案中,確認 compute.networkAdmin 角色已授予給相同專案的 Vertex AI 服務代理程式。如果這個專案與您使用 Vertex AI 的服務專案不同,請預先在這個專案中啟用 Vertex AI API。

    如果您為 Vertex AI 指定要使用的共用 VPC 網路,並在服務專案中建立網路附件,請務必在您使用 Vertex AI 的服務專案中,將 compute.networkUser 角色授予 VPC 主專案的 Vertex AI 服務代理程式

    設定防火牆規則

    輸入防火牆規則會套用至用戶端虛擬私有雲,以便從運算和內部部署端點與 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 對等互連

    如要讓設定 PSC-I 的 Vertex AI Training 工作解析客戶管理的 Cloud DNS 區域中的私有 DNS 記錄,Vertex AI API 提供可供使用者設定的機制,用於指定應對等互連的 DNS 網域。您需要進行下列額外設定。

    1. 將 DNS Peer(roles/dns.peer) 角色指派給您使用 Vertex AI Training 服務的專案的 AI Platform 服務代理帳戶。如果您指定 Vertex AI 使用共用 VPC 網路,並在服務專案中建立網路附件,請務必在您使用 Vertex AI 的服務專案中,將 VPC 主專案的 DNS Peer(roles/dns.peer) 角色授予 AI Platform 服務代理

    2. 建立防火牆規則,允許所有 ICMP、TCP 和 UDP 流量 (選用):

      !gcloud compute firewall-rules create NETWORK-firewall4 \
          --network NETWORK
          --allow tcp:0-65535,udp:0-65535,icmp
          --source-ranges IP_RANGES
      
    3. 設定私人 DNS 區域,用於 DNS 解析和流量路徑。如要在私人 DNS 區域新增 DNS 記錄,請參閱「新增資源記錄集」。

    後續步驟

    • 瞭解如何使用 Private Service Connect 介面輸出,在 Vertex AI 上的 Ray 中執行作業。
    • 瞭解如何使用 Private Service Connect 介面輸出進行自訂訓練
    • 瞭解如何使用 Private Service Connect 介面 egress 搭配 Vertex AI Pipelines