4.10.5.2. GCP에서 VPC 생성
OpenShift Container Platform 클러스터에서 사용할 VPC를 GCP(Google Cloud Platform)에 생성해야 합니다. 요구사항에 맞춰 VPC를 사용자 지정할 수 있습니다. VPC를 생성하는 한 가지 방법은 제공된 Deployment Manager 템플릿을 수정하는 것입니다.
GCP 인프라를 생성하는 데 제공된 Deployment Manager 템플릿을 사용하지 않는 경우, 제공된 정보를 검토하고 수동으로 인프라를 생성해야 합니다. 클러스터가 올바르게 초기화되지 않은 경우, Red Hat 지원팀에 설치 로그를 제시하여 문의해야 할 수도 있습니다.
사전 요구 사항
- GCP 계정을 구성하십시오.
프로세스
-
이 항목의 VPC에 대한 Deployment Manager 템플릿 섹션에서 템플릿을 복사하여 사용자 컴퓨터에
01_vpc.py로 저장합니다. 이 템플릿은 클러스터에 필요한 VPC를 설명합니다. 리소스 정의에 필요한 다음 변수들을 내보냅니다.
컨트롤 플레인 CIDR을 내보냅니다.
$ export MASTER_SUBNET_CIDR='10.0.0.0/19'컴퓨팅 CIDR을 내보냅니다.
$ export WORKER_SUBNET_CIDR='10.0.32.0/19'VPC 네트워크와 클러스터를 배포할 리전을 내보냅니다.
$ export REGION='<region>'
공유 VPC를 호스팅하는 프로젝트의 ID에 해당하는 변수를 내보냅니다.
$ export HOST_PROJECT=<host_project>호스트 프로젝트에 속하는 서비스 계정의 이메일에 해당하는 변수를 내보냅니다.
$ export HOST_PROJECT_ACCOUNT=<host_service_account_email>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>'1 region: '${REGION}'2 master_subnet_cidr: '${MASTER_SUBNET_CIDR}'3 worker_subnet_cidr: '${WORKER_SUBNET_CIDR}'4 EOFgcloudCLI를 사용하여 배포를 생성합니다.$ gcloud deployment-manager deployments create <vpc_deployment_name> --config 01_vpc.yaml --project ${HOST_PROJECT} --account ${HOST_PROJECT_ACCOUNT}1 - 1
<vpc_deployment_name>값으로 배포할 VPC의 이름을 지정합니다.
다른 구성 요소에 필요한 VPC 변수들을 내보냅니다.
호스트 프로젝트 네트워크의 이름을 내보냅니다.
$ export HOST_PROJECT_NETWORK=<vpc_network>호스트 프로젝트 컨트롤 플레인의 이름을 내보냅니다.
$ export HOST_PROJECT_CONTROL_SUBNET=<control_plane_subnet>호스트 프로젝트 컴퓨팅 서브넷의 이름을 내보냅니다.
$ export HOST_PROJECT_COMPUTE_SUBNET=<compute_subnet>
- 공유 VPC를 설정합니다. GCP 문서의 공유 VPC 설정 단원을 참조하십시오.
4.10.5.2.1. VPC용 Deployment Manager 템플릿 링크 복사링크가 클립보드에 복사되었습니다!
다음 Deployment Manager 템플릿을 사용하여 OpenShift Container Platform 클러스터에 필요한 VPC를 배포할 수 있습니다.
예 4.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}