13.8. 在 GCP 中创建 VPC
您必须在 Google Cloud Platform(GCP)中创建一个 VPC,供您的 OpenShift Container Platform 集群使用。您可以自定义 VPC 来满足您的要求。创建 VPC 的一种方法是修改提供的 Deployment Manager 模板。
注意
如果不使用提供的 Deployment Manager 模板来创建 GCP 基础架构,您必须检查提供的信息并手动创建基础架构。如果您的集群没有正确初始化,您可能需要联系红帽支持并提供您的安装日志。
先决条件
- 配置 GCP 帐户。
- 为集群生成 Ignition 配置文件。
流程
-
复制 VPC 的 Deployment Manager 模板一节中的模板, 并将它以
01_vpc.py形式保存到计算机上。此模板描述了集群所需的 VPC。 创建
01_vpc.yaml资源定义文件:$ cat <<EOF >01_vpc.yaml imports: - path: 01_vpc.py resources: - name: cluster-vpc type: 01_vpc.py properties: infra_id: '${INFRA_ID}'1 region: '${REGION}'2 master_subnet_cidr: '${MASTER_SUBNET_CIDR}'3 worker_subnet_cidr: '${WORKER_SUBNET_CIDR}'4 EOF使用
gcloudCLI 创建部署:$ gcloud deployment-manager deployments create ${INFRA_ID}-vpc --config 01_vpc.yaml
13.8.1. VPC 的 Deployment Manager 模板 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
您可以使用以下 Deployment Manager 模板来部署 OpenShift Container Platform 集群所需的 VPC:
例 13.24. 01_VPC.py Deployment Manager 模板
def GenerateConfig(context):
resources = [{
'name': context.properties['infra_id'] + '-network',
'type': 'compute.v1.network',
'properties': {
'region': context.properties['region'],
'autoCreateSubnetworks': False
}
}, {
'name': context.properties['infra_id'] + '-master-subnet',
'type': 'compute.v1.subnetwork',
'properties': {
'region': context.properties['region'],
'network': '$(ref.' + context.properties['infra_id'] + '-network.selfLink)',
'ipCidrRange': context.properties['master_subnet_cidr']
}
}, {
'name': context.properties['infra_id'] + '-worker-subnet',
'type': 'compute.v1.subnetwork',
'properties': {
'region': context.properties['region'],
'network': '$(ref.' + context.properties['infra_id'] + '-network.selfLink)',
'ipCidrRange': context.properties['worker_subnet_cidr']
}
}, {
'name': context.properties['infra_id'] + '-router',
'type': 'compute.v1.router',
'properties': {
'region': context.properties['region'],
'network': '$(ref.' + context.properties['infra_id'] + '-network.selfLink)',
'nats': [{
'name': context.properties['infra_id'] + '-nat-master',
'natIpAllocateOption': 'AUTO_ONLY',
'minPortsPerVm': 7168,
'sourceSubnetworkIpRangesToNat': 'LIST_OF_SUBNETWORKS',
'subnetworks': [{
'name': '$(ref.' + context.properties['infra_id'] + '-master-subnet.selfLink)',
'sourceIpRangesToNat': ['ALL_IP_RANGES']
}]
}, {
'name': context.properties['infra_id'] + '-nat-worker',
'natIpAllocateOption': 'AUTO_ONLY',
'minPortsPerVm': 512,
'sourceSubnetworkIpRangesToNat': 'LIST_OF_SUBNETWORKS',
'subnetworks': [{
'name': '$(ref.' + context.properties['infra_id'] + '-worker-subnet.selfLink)',
'sourceIpRangesToNat': ['ALL_IP_RANGES']
}]
}]
}
}]
return {'resources': resources}