1.8.7. GCP에서 VPC 생성

OpenShift Container Platform 클러스터에서 사용할 VPC를 GCP(Google Cloud Platform)에 생성해야 합니다. 요구사항에 맞춰 VPC를 사용자 지정할 수 있습니다. VPC를 생성하는 한 가지 방법은 제공된 Deployment Manager 템플릿을 수정하는 것입니다.

참고

GCP 인프라를 생성하는 데 제공된 Deployment Manager 템플릿을 사용하지 않는 경우, 제공된 정보를 검토하고 수동으로 인프라를 생성해야 합니다. 클러스터가 올바르게 초기화되지 않은 경우, Red Hat 지원팀에 설치 로그를 제시하여 문의해야 할 수도 있습니다.

사전 요구 사항

  • GCP 계정을 구성하십시오.
  • 클러스터에 대한 Ignition 구성 파일을 생성하십시오.

프로세스

  1. 이 항목의 VPC에 대한 Deployment Manager 템플릿 섹션에서 템플릿을 복사하여 사용자 컴퓨터에 01_vpc.py로 저장합니다. 이 템플릿은 클러스터에 필요한 VPC를 설명합니다.
  2. 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
    1
    infra_id는 추출 단계에서 가져온 INFRA_ID 인프라 이름입니다.
    2
    region은 클러스터를 배포할 영역입니다(예: us-central1).
    3
    master_subnet_cidr은 마스터 서브넷의 CIDR입니다(예: 10.0.0.0/19).
    4
    worker_subnet_cidr은 작업자 서브넷의 CIDR입니다(예: 10.0.32.0/19).
  3. gcloud CLI를 사용하여 배포를 생성합니다.

    $ gcloud deployment-manager deployments create ${INFRA_ID}-vpc --config 01_vpc.yaml

1.8.7.1. VPC용 Deployment Manager 템플릿

다음 Deployment Manager 템플릿을 사용하여 OpenShift Container Platform 클러스터에 필요한 VPC를 배포할 수 있습니다.

예 1.1. 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}