4.11.9. GCP에서 로드 밸런서 생성

OpenShift Container Platform 클러스터가 사용할 로드 밸런서를 GCP(Google Cloud Platform)에 구성해야 합니다. 이러한 구성 요소를 생성하는 한 가지 방법은 제공된 Deployment Manager 템플릿을 수정하는 것입니다.

참고

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

사전 요구 사항

  • GCP 계정을 구성하십시오.
  • 클러스터에 대한 Ignition 구성 파일을 생성하십시오.
  • GCP에서 VPC 및 관련 서브넷을 생성하고 구성하십시오.

프로세스

  1. 이 항목의 내부 로드 밸런서에 대한 Deployment Manager 템플릿 섹션에서 템플릿을 복사하여 사용자 컴퓨터에 02_lb_int.py로 저장합니다. 이 템플릿에서 클러스터에 필요한 내부 로드 밸런싱 개체를 설명합니다.
  2. 외부 클러스터에 대해서도, 이 항목의 외부 로드 밸런서에 대한 Deployment Manager 템플릿 섹션에서 템플릿을 복사하여 사용자 컴퓨터에 02_lb_ext.py로 저장합니다. 이 템플릿에서 클러스터에 필요한 외부 로드 밸런싱 개체를 설명합니다.
  3. 배포 템플릿이 사용하는 변수를 내보냅니다.

    1. 클러스터 네트워크 위치를 내보냅니다.

      $ export CLUSTER_NETWORK=(`gcloud compute networks describe ${INFRA_ID}-network --format json | jq -r .selfLink`)
    2. 컨트롤 플레인 서브넷 위치를 내보냅니다.

      $ export CONTROL_SUBNET=(`gcloud compute networks subnets describe ${INFRA_ID}-master-subnet --region=${REGION} --format json | jq -r .selfLink`)
    3. 클러스터가 사용하는 세 영역을 내보냅니다.

      $ export ZONE_0=(`gcloud compute regions describe ${REGION} --format=json | jq -r .zones[0] | cut -d "/" -f9`)
      $ export ZONE_1=(`gcloud compute regions describe ${REGION} --format=json | jq -r .zones[1] | cut -d "/" -f9`)
      $ export ZONE_2=(`gcloud compute regions describe ${REGION} --format=json | jq -r .zones[2] | cut -d "/" -f9`)
  4. 02_infra.yaml 리소스 정의 파일을 생성합니다.

    $ cat <<EOF >02_infra.yaml
    imports:
    - path: 02_lb_ext.py
    - path: 02_lb_int.py 1
    resources:
    - name: cluster-lb-ext 2
      type: 02_lb_ext.py
      properties:
        infra_id: '${INFRA_ID}' 3
        region: '${REGION}' 4
    - name: cluster-lb-int
      type: 02_lb_int.py
      properties:
        cluster_network: '${CLUSTER_NETWORK}'
        control_subnet: '${CONTROL_SUBNET}' 5
        infra_id: '${INFRA_ID}'
        region: '${REGION}'
        zones: 6
        - '${ZONE_0}'
        - '${ZONE_1}'
        - '${ZONE_2}'
    EOF
    1 2
    외부 클러스터를 배포하는 경우에만 필요합니다.
    3
    infra_id는 추출 단계에서 가져온 INFRA_ID 인프라 이름입니다.
    4
    region은 클러스터를 배포할 영역입니다(예: us-central1).
    5
    control_subnet은 컨트롤 서브넷에 대한 URI입니다.
    6
    zonesus-east1-b, us-east1-cus-east1-d와 같이 컨트롤 플레인 인스턴스를 배포하는 영역입니다.
  5. gcloud CLI를 사용하여 배포를 생성합니다.

    $ gcloud deployment-manager deployments create ${INFRA_ID}-infra --config 02_infra.yaml
  6. 클러스터 IP 주소를 내보냅니다.

    $ export CLUSTER_IP=(`gcloud compute addresses describe ${INFRA_ID}-cluster-ip --region=${REGION} --format json | jq -r .address`)
  7. 외부 클러스터의 경우 클러스터 공용 IP 주소도 내보냅니다.

    $ export CLUSTER_PUBLIC_IP=(`gcloud compute addresses describe ${INFRA_ID}-cluster-public-ip --region=${REGION} --format json | jq -r .address`)

4.11.9.1. 외부 로드 밸런서에 대한 Deployment Manager 템플릿

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

예 4.20. 02_lb_ext.py Deployment Manager 템플릿

def GenerateConfig(context):

    resources = [{
        'name': context.properties['infra_id'] + '-cluster-public-ip',
        'type': 'compute.v1.address',
        'properties': {
            'region': context.properties['region']
        }
    }, {
        # Refer to docs/dev/kube-apiserver-health-check.md on how to correctly setup health check probe for kube-apiserver
        'name': context.properties['infra_id'] + '-api-http-health-check',
        'type': 'compute.v1.httpHealthCheck',
        'properties': {
            'port': 6080,
            'requestPath': '/readyz'
        }
    }, {
        'name': context.properties['infra_id'] + '-api-target-pool',
        'type': 'compute.v1.targetPool',
        'properties': {
            'region': context.properties['region'],
            'healthChecks': ['$(ref.' + context.properties['infra_id'] + '-api-http-health-check.selfLink)'],
            'instances': []
        }
    }, {
        'name': context.properties['infra_id'] + '-api-forwarding-rule',
        'type': 'compute.v1.forwardingRule',
        'properties': {
            'region': context.properties['region'],
            'IPAddress': '$(ref.' + context.properties['infra_id'] + '-cluster-public-ip.selfLink)',
            'target': '$(ref.' + context.properties['infra_id'] + '-api-target-pool.selfLink)',
            'portRange': '6443'
        }
    }]

    return {'resources': resources}