本指南說明如何為 Vertex AI 資源設定 Private Service Connect 介面。
您可以為 Vertex AI 中的特定資源設定 Private Service Connect 介面連線,包括:
與 VPC 對等互連連線不同,Private Service Connect 介面連線是可遞移的。這樣一來,消費者虛擬私有雲網路中需要的 IP 位址就會減少。因此您可以更彈性地連線至 Google Cloud 專案和地端中的其他虛擬私有雲網路。
本指南適用於熟悉 Google Cloud 網路概念的網路管理員。
目標
本指南涵蓋下列工作:
- 設定生產者虛擬私有雲 網路、子網路和網路連結。
- 在 Google Cloud 網路主專案中新增防火牆規則。
- 建立 Vertex AI 資源,並指定要使用 Private Service Connect 介面的網路附件。
事前準備
按照下列操作說明建立或選取 Google Cloud 專案,並設定專案以搭配 Vertex AI 和 Private Service Connect 使用。
- 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.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Verify that billing is enabled for your Google Cloud project.
-
Enable the Vertex AI, Compute Engine, and Cloud Storage APIs.
-
Install the Google Cloud CLI.
-
如果您使用外部識別資訊提供者 (IdP),請先 使用聯合身分登入 gcloud CLI。
-
如要初始化 gcloud CLI,請執行下列指令:
gcloud init
-
初始化 gcloud CLI 後,請更新並安裝必要元件:
gcloud components update gcloud components install beta
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Verify that billing is enabled for your Google Cloud project.
-
Enable the Vertex AI, Compute Engine, and Cloud Storage APIs.
-
Install the Google Cloud CLI.
-
如果您使用外部識別資訊提供者 (IdP),請先 使用聯合身分登入 gcloud CLI。
-
如要初始化 gcloud CLI,請執行下列指令:
gcloud init
-
初始化 gcloud CLI 後,請更新並安裝必要元件:
gcloud components update gcloud components install beta
- 如果您不是專案擁有者,且沒有專案 IAM 管理員 (
roles/resourcemanager.projectIamAdmin
) 角色,請要求擁有者授予您包含compute.networkAttachments.update
權限的 IAM 角色 (例如 Compute Network Admin (roles/compute.networkAdmin
) 角色),以便管理網路資源。 - 將網路主機 Google Cloud 專案的 Compute Network Admin 角色指派給AI Platform 服務代理人帳戶,該帳戶所屬專案是您使用 Vertex AI Training 或 Vertex AI Agent Engine 服務的專案。
-
gcloud compute networks create NETWORK \ --subnet-mode=custom
將 NETWORK 替換為虛擬私有雲網路的名稱。
-
gcloud compute networks subnets create SUBNET_NAME \ --network=NETWORK \ --range=PRIMARY_RANGE \ --region=REGION
更改下列內容:
- SUBNET_NAME:子網路的名稱。
PRIMARY_RANGE:新子網路的主要 IPv4 範圍,採用 CIDR 標記法。
以下是 Vertex AI 的 IP 規定和限制:
- Vertex AI 會建議
/28
子網路。 - 網路附件的子網路支援 RFC 1918 和非 RFC 1918 位址,但 100.64.0.0/10 和 240.0.0.0/4 子網路除外。
- Vertex AI 只能連線至可從指定網路路由傳輸的 RFC 1918 IP 位址範圍。
Vertex AI 無法連線至私用公開 IP 位址,或下列非 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
詳情請參閱「IPv4 子網路範圍」。
- Vertex AI 會建議
REGION:您建立新子網路的 Google Cloud 區域。
建立防火牆規則,允許透過 TCP 通訊埠 22 進行 SSH 存取:
gcloud compute firewall-rules create NETWORK-firewall1 \ --network NETWORK \ --allow tcp:22
建立防火牆規則,允許 TCP 通訊埠 443 上的 HTTPS 流量:
gcloud compute firewall-rules create NETWORK-firewall2 \ --network NETWORK \ --allow tcp:443
建立允許 ICMP 流量 (例如 ping 要求) 的防火牆規則:
gcloud compute firewall-rules create NETWORK-firewall3 \ --network NETWORK \ --allow icmp
將 DNS
Peer(roles/dns.peer)
角色指派給您使用 Vertex AI Training 或 Vertex AI Agent Engine 服務的專案的 AI Platform 服務代理帳戶。如果您指定 Vertex AI 使用共用虛擬私有雲網路,並在服務專案中建立網路附件,請在您使用 Vertex AI 的服務專案中,為 AI Platform 服務代理授予虛擬私有雲主專案的 DNSPeer(roles/dns.peer)
角色。建立防火牆規則,允許所有 ICMP、TCP 和 UDP 流量 (選用):
gcloud compute firewall-rules create NETWORK-firewall4 \ --network NETWORK --allow tcp:0-65535,udp:0-65535,icmp --source-ranges IP_RANGES
設定私人 DNS 區域,用於 DNS 解析和流量路徑。如要在私人 DNS 區域新增 DNS 記錄,請參閱「新增資源記錄集」。
- 瞭解如何使用 Private Service Connect 介面輸出,在 Vertex AI 上的 Ray 中執行作業。
- 瞭解如何使用 Private Service Connect 介面輸出進行自訂訓練。
- 瞭解如何使用 Private Service Connect 介面 egress 搭配 Vertex AI Pipelines。
- 瞭解如何使用 Private Service Connect 介面輸出,適用於 Vertex AI Agent Engine
設定虛擬私有雲網路和子網路
如果沒有現有網路,請按照設定步驟建立新的虛擬私有雲網路。
建立網路連結
在共用虛擬私有雲部署作業中,請在主專案中建立用於網路附件的子網路,然後在服務專案中建立 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 使用共用虛擬私有雲網路,並在服務專案中建立網路附件,請在您使用 Vertex AI 的服務專案中,將 compute.networkUser
角色授予虛擬私有雲主專案的 Vertex AI 服務代理程式。
設定防火牆規則
系統會在用戶端虛擬私有雲中套用連入防火牆規則,允許運算和內部部署端點與 Private Service Connect 介面網路連結子網路通訊。
您可以視需要設定防火牆規則。不過,我們建議您設定常見的防火牆規則,如下列範例所示。
設定私人 DNS 對等互連
如要讓設定 PSC-I 的 Vertex AI Training 工作或 Vertex AI Agent Engine 代理程式,解析客戶管理的 Cloud DNS 區域中的私人 DNS 記錄,Vertex AI API 提供使用者可設定的機制,指定要與 Google 內部資源對等互連的 DNS 網域。進行下列額外設定:
疑難排解
本節說明設定 Private Service Connect 與 Vertex AI 時,可能會遇到的一些常見問題。
使用共用 VPC 設定 Vertex AI 時,請在您使用 Vertex AI 的服務專案中建立網路附件。這個方法可確保在正確的專案中啟用必要權限和 API,有助於避免出現特定錯誤訊息,例如「請確認專案已啟用 Vertex AI API」。