This documentation is for a release that is no longer maintained
See documentation for the latest supported version 3 or the latest supported version 4.1.9.5.2. 在 GCP 中创建 VPC
您必须在 Google Cloud Platform (GCP) 中创建一个 VPC,供您的 OpenShift Container Platform 集群使用。您可以自定义 VPC 来满足您的要求。创建 VPC 的一种方法是修改提供的 Deployment Manager 模板。
如果不使用提供的 Deployment Manager 模板来创建 GCP 基础架构,您必须检查提供的信息并手动创建基础架构。如果集群没有正确初始化,您可能需要联系红帽支持并提供您的安装日志。
先决条件
- 配置 GCP 帐户。
流程
-
复制 VPC 的 Deployment Manager 模板一节中的模板,并将它以
01_vpc.py
形式保存到计算机上。此模板描述了集群所需的 VPC。 导出资源定义所需的以下变量:
导出 control plane CIDR:
export MASTER_SUBNET_CIDR='10.0.0.0/19'
$ export MASTER_SUBNET_CIDR='10.0.0.0/19'
Copy to Clipboard Copied! 导出计算 CIDR:
export WORKER_SUBNET_CIDR='10.0.32.0/19'
$ export WORKER_SUBNET_CIDR='10.0.32.0/19'
Copy to Clipboard Copied! 将部署 VPC 网络和集群的区域导出到:
export REGION='<region>'
$ export REGION='<region>'
Copy to Clipboard Copied!
导出托管共享 VPC 的项目 ID 的变量:
export HOST_PROJECT=<host_project>
$ export HOST_PROJECT=<host_project>
Copy to Clipboard Copied! 导出属于主机项目的服务帐户电子邮件的变量:
export HOST_PROJECT_ACCOUNT=<host_service_account_email>
$ export HOST_PROJECT_ACCOUNT=<host_service_account_email>
Copy to Clipboard Copied! 创建
01_vpc.yaml
资源定义文件:cat <<EOF >01_vpc.yaml imports: - path: 01_vpc.py resources: - name: cluster-vpc type: 01_vpc.py properties: infra_id: '<prefix>' region: '${REGION}' master_subnet_cidr: '${MASTER_SUBNET_CIDR}' worker_subnet_cidr: '${WORKER_SUBNET_CIDR}' EOF
$ cat <<EOF >01_vpc.yaml imports: - path: 01_vpc.py resources: - name: cluster-vpc type: 01_vpc.py properties: infra_id: '<prefix>'
1 region: '${REGION}'
2 master_subnet_cidr: '${MASTER_SUBNET_CIDR}'
3 worker_subnet_cidr: '${WORKER_SUBNET_CIDR}'
4 EOF
Copy to Clipboard Copied! 使用
gcloud
CLI 创建部署:gcloud deployment-manager deployments create <vpc_deployment_name> --config 01_vpc.yaml --project ${HOST_PROJECT} --account ${HOST_PROJECT_ACCOUNT}
$ gcloud deployment-manager deployments create <vpc_deployment_name> --config 01_vpc.yaml --project ${HOST_PROJECT} --account ${HOST_PROJECT_ACCOUNT}
1 Copy to Clipboard Copied! - 1
- 对于
<vpc_deployment_name>
,请指定要部署的 VPC 名称。
导出其他组件需要的 VPC 变量:
导出主机项目网络的名称:
export HOST_PROJECT_NETWORK=<vpc_network>
$ export HOST_PROJECT_NETWORK=<vpc_network>
Copy to Clipboard Copied! 导出主机项目 control plane 子网的名称:
export HOST_PROJECT_CONTROL_SUBNET=<control_plane_subnet>
$ export HOST_PROJECT_CONTROL_SUBNET=<control_plane_subnet>
Copy to Clipboard Copied! 导出主机项目计算子网的名称:
export HOST_PROJECT_COMPUTE_SUBNET=<compute_subnet>
$ export HOST_PROJECT_COMPUTE_SUBNET=<compute_subnet>
Copy to Clipboard Copied!
- 设置共享 VPC。请参阅 GCP 文档中的 设置共享 VPC。
1.9.5.2.1. VPC 的 Deployment Manager 模板
您可以使用以下 Deployment Manager 模板来部署 OpenShift Container Platform 集群所需的 VPC:
例 1.10. 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}
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}