4.9.9. GCP でのロードバランサーの作成

OpenShift Container Platform クラスターで使用するロードバランシングを Google Cloud Platform (GCP) で設定する必要があります。これらのコンポーネントを作成する方法として、提供される Deployment Manager テンプレートを変更することができます。

注記

提供される Deployment Manager テンプレートを使用して GCP インフラストラクチャーを使用しない場合、提供される情報を確認し、インフラストラクチャーを手動で作成する必要があります。クラスターが適切に初期化されない場合、インストールログを用意して 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. クラスターが使用する 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 は、コントロールサブセットの URL です。
    6
    zones は、コントロールプレーンインスタンスをデプロイするゾーンです (例: us-east1-bus-east1-c、および us-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.9.9.1. 外部ロードバランサーの Deployment Manager テンプレート

以下の Deployment Manager テンプレートを使用して、OpenShift Container Platform クラスターに必要な外部ロードバランサーをデプロイすることができます。

例4.2 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}