您可以透過代理程式註冊資料庫,手動將目標網址 (例如外部 REST API) 註冊為代管端點,集中管理代理程式群可以連線的目的地。
us 和 eu 多區域位置不支援端點註冊,您必須使用支援的區域或 global 位置。詳情請參閱「代理程式登錄檔位置」。
事前準備
- 設定 Agent Registry。
如要使用本文件中的 Google Cloud CLI 指令,請設定 gcloud CLI 環境。
必要的角色
如要取得在 Agent Registry 註冊端點所需的權限,請要求管理員在已啟用 Agent Registry 的管理專案中,授予您 Agent Registry API 編輯者 (roles/agentregistry.editor) IAM 角色。如要進一步瞭解如何授予角色,請參閱「管理專案、資料夾和組織的存取權」。
註冊端點
端點是自訂的外部目的地,因此請使用手動註冊,將端點新增至 Agent Registry:
控制台
前往 Google Cloud 控制台的「Agent Registry」:
在專案挑選器中,選取設定 Agent Registry 的 Google Cloud 專案。
選取「Endpoints」分頁標籤。
按一下「新增端點」。
在「Endpoint details」(端點詳細資料) 面板中,輸入顯示名稱、說明、地理區域和到達網頁網址。
您也可以點選這個面板中的「Test connection」(測試連線),測試與到達網頁網址的連線。
按一下 [儲存]。
gcloud
您使用的規格旗標會決定元件所屬的資源集合。如需旗標與資源集合的完整對應關係,請參閱「[服務資源和探索資源](/agent-registry/data-model#service-resources)」。
如要將端點新增至 Agent Registry,請使用 gcloud agent-registry services create 指令建立 Service 資源,並將 --endpoint-spec-type 旗標設為 no-spec:
gcloud agent-registry services create ENDPOINT_NAME \
--project=PROJECT_ID \
--location=REGION \
--display-name="DISPLAY_NAME" \
--endpoint-spec-type=no-spec \
--interfaces=url=ENDPOINT_URL,protocolBinding=PROTOCOL
更改下列內容:
ENDPOINT_NAME:要為端點指定的名稱,例如my-external-api。名稱長度必須介於 4 到 63 個半形字元之間,且只能使用小寫英文字母、數字和連字號。PROJECT_ID:專案 ID。REGION:登錄檔區域。DISPLAY_NAME:端點的人類可讀名稱,例如My External API。ENDPOINT_URL:目標網址,例如https://api.example.com/v1/data。PROTOCOL:介面的通訊協定繫結。有效值為http-json、grpc或jsonrpc。
建立 Service 資源後,Agent Registry 會自動產生唯讀的 Endpoint 資源,供代理和自動化調度管理工具探索及使用。
Terraform
您設定的規格區塊會決定元件所屬的資源集合。如需規格與資源集合的完整對應關係,請參閱「[服務資源和探索資源](/agent-registry/data-model#service-resources)」。
如要註冊外部端點,請使用 endpoint_spec 區塊設定 google_agent_registry_service 資源:
resource "google_agent_registry_service" "endpoint" {
location = "REGION"
service_id = "ENDPOINT_NAME"
display_name = "DISPLAY_NAME"
description = "An external REST API registered using Terraform."
interfaces {
url = "ENDPOINT_URL"
protocol_binding = "PROTOCOL"
}
endpoint_spec {
type = "NO_SPEC"
}
}
output "endpoint_resource_name" {
description = "The generated read-only Endpoint resource name."
value = google_agent_registry_service.endpoint.registry_resource
}
更改下列內容:
REGION:登錄檔區域。ENDPOINT_NAME:要為端點指定的專屬名稱,例如my-external-api。名稱長度必須介於 4 到 63 個字元之間,且只能包含小寫英文字母、數字和連字號。DISPLAY_NAME:端點的人類可讀名稱,例如My External API。ENDPOINT_URL:目標網址,例如https://api.example.com/v1/data。PROTOCOL:介面的通訊協定繫結。有效值為HTTP_JSON、GRPC或JSONRPC。
註冊複合式 Google API 端點
在跨專案架構中,中央管理專案會託管共用基礎架構,例如代理程式註冊資料庫和 Agent Gateway,而獨立的 Google Cloud 專案則會託管代理程式運算執行個體。
在輸出模式下,透過 Agent Gateway 轉送代理流量時,系統預設會封鎖傳出網路流量。如要讓不同 Google Cloud 專案中的代理與必要的Google Cloud API 通訊,您可以將多個 API 介面分組,在中央管理專案中建立單一複合Service資源。
將介面整合至單一端點,即可簡化政策管理作業,讓您為整套核心 Google API 管理單一 Identity-Aware Proxy (IAP) 政策繫結。
請按照下列步驟註冊複合 Google API 端點:
gcloud
使用 gcloud agent-registry services create 指令,在中央管理專案中註冊具有多個介面網址的端點:
gcloud agent-registry services create SERVICE_NAME \
--project=CENTRAL_PROJECT_ID \
--location=REGION \
--display-name="DISPLAY_NAME" \
--description="DESCRIPTION" \
--endpoint-spec-type=no-spec \
--interfaces=protocolBinding=jsonrpc,url=API_URL \
--interfaces=protocolBinding=jsonrpc,url=ADDITIONAL_API_URL
更改下列內容:
SERVICE_NAME:服務的 ID,例如core-gapi-services。名稱長度必須介於 4 到 63 個字元之間,且只能包含小寫英文字母、數字和連字號。CENTRAL_PROJECT_ID:託管 Agent Registry 和 Agent Gateway 的中央管理專案 ID。REGION:閘道和登錄檔所在的區域。DISPLAY_NAME:人類可讀的名稱,例如Core Google APIs。DESCRIPTION:簡短說明,例如Essential Google APIs for agent operations。API_URL:主要 Google API 的網址,例如https://telemetry.googleapis.com。ADDITIONAL_API_URL:針對代理程式所需的每個額外 Google API 網址或變體,重複使用--interfaces旗標,例如https://cloudresourcemanager.googleapis.com、https://iamcredentials.googleapis.com、https://agentregistry.googleapis.com,或區域和 mTLS 變體,例如https://telemetry.mtls.googleapis.com。
Terraform
如要使用 Terraform 註冊複合 Google API 端點,請使用多個 interfaces 區塊定義 google_agent_registry_service 資源:
resource "google_agent_registry_service" "core_gapi_services" {
project = "CENTRAL_PROJECT_ID"
location = "REGION"
service_id = "SERVICE_NAME"
display_name = "DISPLAY_NAME"
description = "DESCRIPTION"
endpoint_spec {
type = "NO_SPEC"
}
interfaces {
url = "API_URL"
protocol_binding = "JSONRPC"
}
# Add an interfaces block for each additional Google API URL
interfaces {
url = "ADDITIONAL_API_URL"
protocol_binding = "JSONRPC"
}
}
更改下列內容:
CENTRAL_PROJECT_ID:中央管理專案的專案 ID。REGION:登錄檔區域。SERVICE_NAME:服務 ID,例如core-gapi-services。名稱長度必須介於 4 到 63 個字元之間,且只能包含小寫英文字母、數字和連字號。DISPLAY_NAME:人類可讀的名稱,例如Core Google APIs。DESCRIPTION:端點說明。API_URL:主要 Google API 的網址,例如https://telemetry.googleapis.com。ADDITIONAL_API_URL:針對代理程式所需的每個額外 Google API 網址或變體,重複interfaces區塊,例如https://cloudresourcemanager.googleapis.com、https://iamcredentials.googleapis.com、https://agentregistry.googleapis.com,或區域和 mTLS 變體,例如https://telemetry.mtls.googleapis.com。
後續步驟
- 瞭解如何管理及探索已註冊的端點。
- 瞭解如何為已註冊的端點設定 Identity and Access Management (IAM) 輸出政策。