1.3.18. コントロールプレーンマシンの作成

生成した Ignition 設定ファイルを使用して 3 つのコントロールプレーンマシンを作成します。

前提条件

  • インストールプログラムのメタデータファイルのインフラストラクチャー ID は環境変数 ($INFRA_ID) として設定されます。
  • 共通ディレクトリー内の inventory.yaml および common.yaml Ansible Playbook。

    • これらのファイルが必要な場合は、ネットワークリソースの作成からこれらのファイルをコピーします。
  • コントロールプレーン Ignition 設定ファイルの作成で作成された 3 つの Ignition ファイル。

手順

  1. コマンドラインで、作業ディレクトリーを inventory.yaml および common.yaml ファイルの場所に変更します。
  2. コントロールプレーン Ignition 設定ファイルが作業ディレクトリーにない場合、それらをここにコピーします。
  3. control-plane.yaml というローカルファイルに、以下のコンテンツを挿入します。

    例1.6 control-plane.yaml

    # Required Python packages:
    #
    # ansible
    # openstackclient
    # openstacksdk
    # netaddr
    
    - import_playbook: common.yaml
    
    - hosts: all
      gather_facts: no
    
      tasks:
      - name: 'Create the Control Plane ports'
        os_port:
          name: "{{ item.1 }}-{{ item.0 }}"
          network: "{{ os_network }}"
          security_groups:
          - "{{ os_sg_master }}"
          allowed_address_pairs:
          - ip_address: "{{ os_subnet_range | next_nth_usable(5) }}"
          - ip_address: "{{ os_subnet_range | next_nth_usable(6) }}"
          - ip_address: "{{ os_subnet_range | next_nth_usable(7) }}"
        with_indexed_items: "{{ [os_port_master] * os_cp_nodes_number }}"
        register: ports
    
      - name: 'Set Control Plane ports tag'
        command:
          cmd: "openstack port set --tag {{ cluster_id_tag }} {{ item.1 }}-{{ item.0 }}"
        with_indexed_items: "{{ [os_port_master] * os_cp_nodes_number }}"
    
      - name: 'List the Control Plane Trunks'
        command:
          cmd: "openstack network trunk list"
        when: os_networking_type == "Kuryr"
        register: control_plane_trunks
    
      - name: 'Create the Control Plane trunks'
        command:
          cmd: "openstack network trunk create --parent-port {{ item.1.id }} {{ os_cp_trunk_name }}-{{ item.0 }}"
        with_indexed_items: "{{ ports.results }}"
        when:
        - os_networking_type == "Kuryr"
        - "os_cp_trunk_name|string not in control_plane_trunks.stdout"
    
      - name: 'List the Server groups'
        command:
          cmd: "openstack server group list -f json -c ID -c Name"
        register: server_group_list
    
      - name: 'Parse the Server group ID from existing'
        set_fact:
          server_group_id: "{{ (server_group_list.stdout | from_json | json_query(list_query) | first).ID }}"
        vars:
          list_query: "[?Name=='{{ os_cp_server_group_name }}']"
        when:
        - "os_cp_server_group_name|string in server_group_list.stdout"
    
      - name: 'Create the Control Plane server group'
        command:
          cmd: "openstack --os-compute-api-version=2.15 server group create -f json -c id --policy=soft-anti-affinity {{ os_cp_server_group_name }}"
        register: server_group_created
        when:
        - server_group_id is not defined
    
      - name: 'Parse the Server group ID from creation'
        set_fact:
          server_group_id: "{{ (server_group_created.stdout | from_json).id }}"
        when:
        - server_group_id is not defined
    
      - name: 'Create the Control Plane servers'
        os_server:
          name: "{{ item.1 }}-{{ item.0 }}"
          image: "{{ os_image_rhcos }}"
          flavor: "{{ os_flavor_master }}"
          auto_ip: no
          # The ignition filename will be concatenated with the Control Plane node
          # name and its 0-indexed serial number.
          # In this case, the first node will look for this filename:
          #    "{{ infraID }}-master-0-ignition.json"
          userdata: "{{ lookup('file', [item.1, item.0, 'ignition.json'] | join('-')) | string }}"
          nics:
          - port-name: "{{ os_port_master }}-{{ item.0 }}"
          scheduler_hints:
            group: "{{ server_group_id }}"
        with_indexed_items: "{{ [os_cp_server_name] * os_cp_nodes_number }}"
  4. コマンドラインで Playbook を実行します。

    $ ansible-playbook -i inventory.yaml control-plane.yaml
  5. 以下のコマンドを実行してブートストラッププロセスをモニターします。

    $ openshift-install wait-for bootstrap-complete

    コントロールプレーンマシンが実行され、クラスターに参加していることを確認できるメッセージが表示されます。

    INFO API v1.14.6+f9b5405 up
    INFO Waiting up to 30m0s for bootstrapping to complete...
    ...
    INFO It is now safe to remove the bootstrap resources