私人集區設定檔結構定義

私人集區設定檔包含讓 Cloud Build 依據您的規格建立私人集區的操作說明。私人集區設定檔包含磁碟大小和機型等資訊,供您用於私人集區。使用 gcloud 工具或 Cloud Build API 建立及管理私人集區時,必須提供私人集區設定檔。

私人集區設定檔的結構

您可以使用 YAML 或 JSON 語法撰寫私人集區設定檔。如要使用 curl 建立及管理私人集區,請以 JSON 格式撰寫私人集區設定檔。如要使用 gcloud 工具建立及管理私人集區,請以 YAML 或 JSON 格式撰寫私人集區設定檔。

私人集區設定檔的結構如下:

YAML

privatePoolV1Config:
  networkConfig:
    egressOption: NO_PUBLIC_EGRESS
    peeredNetwork: 'PEERED_NETWORK'
    peeredNetworkIpRange: 'PEERED_NETWORK_IP_RANGE'
  workerConfig:
    diskSizeGb: 'PRIVATE_POOL_DISK_SIZE'
    machineType: PRIVATE_POOL_MACHINE_TYPE

JSON

{
  "privatePoolV1Config": {
    "networkConfig": {
      "egressOption": "NO_PUBLIC_EGRESS",
      "peeredNetwork": "PEERED_NETWORK",
      "peeredNetworkIpRange": "PEERED_NETWORK_IP_RANGE"
    },
    "workerConfig": {
      "diskSizeGb": "PRIVATE_POOL_DISK_SIZE",
      "machineType": "PRIVATE_POOL_MACHINE_TYPE"
    }
  }
}

私人集區設定檔中的欄位說明如下:

networkConfig

此為選填欄位。只有在將 VPC 網路與服務供應商網路對等互連時,才需要指定 networkConfig

egressOption

此為選填欄位。如果您要在 VPC Service Controls 範圍內建立私人集區,請將這個欄位的值設為 NO_PUBLIC_EGRESS。如果未在私人集區設定檔中加入這個欄位,系統會啟用公開輸出。 如要瞭解如何為私人集區設定 VPC Service Controls,請參閱使用 VPC Service Controls

peeredNetwork

如果私人集區設定檔包含 networkConfig 欄位,則這是必填欄位。將這個欄位的值設為與服務生產端網路對等互連的虛擬私有雲網路資源網址。網路資源網址的格式必須為 projects/NETWORK_PROJECT_ID/global/networks/NETWORK_NAME,其中 NETWORK_PROJECT_ID 是保存虛擬私有雲網路的 Google Cloud 專案 ID,NETWORK_NAME 則是虛擬私有雲網路的名稱。如果您未指定值,Cloud Build 預設會使用服務生產者網路

peeredNetworkIpRange

此為選填欄位。設定這個欄位的值,指定 VM 可在對等互連網路的已分配範圍內指派的內部 IP 範圍。如果指定的 IP 範圍無法在私人連線範圍內分配 (例如因大小限制或起始 IP 無效),則無法建立私人集區。

peeredNetworkIpRange 是以無類別跨網域路由 (CIDR) 標記法指定,格式為 'STARTING_IP/SUBNET_PREFIX_SIZE'。如果使用這個欄位,就必須指定 SUBNET_PREFIX_SIZESUBNET_PREFIX_SIZE 決定 IP 範圍的大小。開頭必須為斜線 (/),且值須小於或等於 29。STARTING_IP 部分為選用,可指定範圍的起始位址。如果未指定 STARTING_IP,系統會從私人連線範圍內自動指派起始位址。如果未指定 peeredNetworkIpRange 的值,系統會使用 /24 的預設值,自動指派 IP 範圍為 256 個 IP 的起始 IP。

SUBNET_PREFIX_SIZE 的值不得超過 29。數字越大,代表子網路前置越大,可用的 IP 就越少,IP 範圍也會越小。由於 IP 位址為 32 位元,前置大小為 /24 時,範圍內可有 256 個可能的 IP (八位元),而前置大小為 /29 時,則有八個可能的 IP (三位元)。建構工具 VM 的數量上限,取決於範圍內可用的 IP 數量 (範圍內可能的 IP 總數減去兩個)。

如需 peeredNetworkIpRange 欄位的範例,請參閱下列內容:

  • 192.168.0.0/24 指定的 IP 範圍從 192.168.0.0 開始,子網路前置大小為 24 (256 個 IP,其中 254 個可用)。
  • /29 指定的範圍會自動決定起始 IP,子網路前置字串大小為 29 (八個 IP,其中六個可用)。

workerConfig

這是必填欄位。其中包含私人集區的設定選項。

diskSizeGb

此為選填欄位。使用這個欄位,以 GB 為單位指定私人集區執行個體的磁碟大小。請指定大於或等於 100 且小於或等於 4000 的值。如果未在私有集區設定檔中加入這個欄位,或是將這個欄位的值指定為 0,Cloud Build 會使用預設值 100。

machineType

此為選填欄位。使用這個欄位,為私人集區執行個體指定 Compute Engine 機器類型。如未指定值,Cloud Build 會使用預設值 e2-medium。否則,請指定下列其中一種機器類型:

機器類型

e2 n2d c3
e2-medium n2d-standard-2 c3-standard-4
e2-standard-2 n2d-standard-4 c3-standard-8
e2-standard-4 n2d-standard-8 c3-standard-22
e2-standard-8 n2d-standard-16 c3-standard-44
e2-standard-16 n2d-standard-32 c3-standard-88
e2-standard-32 n2d-standard-48 c3-standard-176
e2-highmem-2 n2d-standard-64 c3-highcpu-4
e2-highmem-4 n2d-standard-80 c3-highcpu-8
e2-highmem-8 n2d-standard-96 c3-highcpu-22
e2-highmem-16 n2d-standard-128 c3-highcpu-44
e2-highcpu-2 n2d-standard-224 c3-highcpu-88
e2-highcpu-4 n2d-highmem-2 c3-highcpu-176
e2-highcpu-8 n2d-highmem-4 c3-highmem-4
e2-highcpu-16 n2d-highmem-8 c3-highmem-8
e2-highcpu-32 n2d-highmem-16 c3-highmem-22
n2d-highmem-32 c3-highmem-44
n2d-highmem-48 c3-highmem-88
n2d-highmem-64 c3-highmem-176
n2d-highmem-80
n2d-highmem-96
n2d-highcpu-2
n2d-highcpu-4
n2d-highcpu-8
n2d-highcpu-16
n2d-highcpu-32
n2d-highcpu-48
n2d-highcpu-64
n2d-highcpu-80
n2d-highcpu-96
n2d-highcpu-128
n2d-highcpu-224

下表列出各區域可用的機器類型:

各區域的機器類型可用性

c3-standard-* c3-highcpu-* c3-highmem-* e2-* n2d-*
asia-northeast1 asia-southeast1 asia-southeast1 africa-south1 africa-south1
asia-southeast1 europe-west1 europe-west1 asia-east1 asia-east1
australia-southeast1 europe-west3 europe-west2 asia-east2 asia-east2
europe-west1 europe-west4 europe-west3 asia-northeast1 asia-northeast1
europe-west2 me-central2 europe-west4 asia-northeast2 asia-northeast2
europe-west3 us-central1 us-central1 asia-northeast3 asia-northeast3
europe-west4 us-east1 us-east1 asia-south1 asia-south1
europe-west9 us-east4 us-east4 asia-south2 asia-south2
me-central2 us-east5 us-east5 asia-southeast1 asia-southeast1
me-west1 us-west2 us-west1 asia-southeast2 asia-southeast2
northamerica-northeast1 us-west3 us-west2 australia-southeast1 australia-southeast1
southamerica-east1 us-west4 australia-southeast2 australia-southeast2
us-central1 europe-central2 europe-central2
us-east1 europe-north1 europe-north1
us-east4 europe-north2 europe-southwest1
us-east5 europe-southwest1 europe-west1
us-west1 europe-west1 europe-west10
us-west2 europe-west2 europe-west12
us-west3 europe-west3 europe-west2
us-west4 europe-west4 europe-west3
europe-west6 europe-west4
europe-west8 europe-west6
europe-west9 europe-west8
europe-west10 europe-west9
europe-west12 me-central1
me-central1 me-central2
me-central2 me-west1
me-west1 northamerica-northeast1
northamerica-northeast1 northamerica-northeast2
northamerica-northeast2 southamerica-east1
northamerica-south1 southamerica-west1
southamerica-east1 us-central1
southamerica-west1 us-east1
us-central1 us-east4
us-east1 us-east5
us-east4 us-south1
us-east5 us-west1
us-south1 us-west2
us-west1 us-west3
us-west2 us-west4
us-west3
us-west4

enableNestedVirtualization

此為選填欄位。如果私人集區使用具有 C3 機型類型的 VM,您可以啟用巢狀虛擬化,在私人集區的 VM 中執行其他 VM 執行個體。詳情請參閱「關於巢狀虛擬化」。

後續步驟