私有池配置文件(私有池配置文件)中包含 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
字段,则此字段为必填字段。将此字段的值设置为与服务提供方网络对等互连的 VPC 网络的网络资源网址。网络资源网址必须采用格式 projects/NETWORK_PROJECT_ID/global/networks/NETWORK_NAME
,其中 NETWORK_PROJECT_ID 是 VPC 网络所在的 Google Cloud 项目的 ID,NETWORK_NAME 是 VPC 网络的名称。如果未指定值,则 Cloud Build 默认使用服务提供方网络。
peeredNetworkIpRange
这是一个可选字段。设置此字段的值,以指定可在对等互连网络的已分配范围内分配给虚拟机的内部 IP 范围。如果无法在专用连接的范围内分配指定的 IP 范围(例如,由于大小限制或起始 IP 无效),则无法创建专用池。
peeredNetworkIpRange
使用无类别域间路由 (CIDR) 表示法指定,格式为 'STARTING_IP/SUBNET_PREFIX_SIZE'
。如果使用此字段,则必须指定 SUBNET_PREFIX_SIZE
。
SUBNET_PREFIX_SIZE
确定 IP 地址范围的大小。它必须以斜杠 (/
) 开头,且值小于或等于 29。STARTING_IP
部分是可选的,用于指定范围的起始地址。如果未指定 STARTING_IP
,系统会自动从专用连接范围内分配起始地址。如果未为 peeredNetworkIpRange
指定值,系统将使用默认值 /24
,该值会自动分配一个包含 256 个 IP 的起始 IP。
SUBNET_PREFIX_SIZE
的值不得超过 29。数字越大,指定的子网前缀就越大,这会减少可能的 IP 数量,并导致 IP 范围变小。由于 IP 地址为 32 位,因此前缀大小为 /24
时,范围中允许有 256 个可能的 IP 地址(8 位),而前缀大小为 /29
时,范围中只允许有 8 个可能的 IP 地址(3 位)。构建器虚拟机的最大数量受范围中可用 IP 的数量限制(范围中可能的 IP 总数减去 2)。
如需查看 peeredNetworkIpRange
字段的示例,请参阅以下内容:
192.168.0.0/24
指定了一个从 192.168.0.0 开始的 IP 范围,子网前缀大小为 24(256 个 IP,其中 254 个可用 IP)。/29
指定了一个范围,其中包含自动确定的起始 IP 和 29 的子网前缀大小(8 个 IP,其中 6 个可用 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
机器类型的虚拟机,则可以启用嵌套虚拟化,以便在专用池的虚拟机内运行其他虚拟机实例。如需了解详情,请参阅关于嵌套虚拟化。