8.7.3. 独自のインフラストラクチャーを使用する RHOSP のクラスターの削除


独自のインフラストラクチャーを使用する Red Hat OpenStack Platform (RHOSP) の OpenShift Container Platform クラスターを削除できます。削除プロセスを迅速に完了するには、複数の Ansible Playbook を作成し、実行します。

前提条件

  • Python 3 がマシンにインストールされています。
  • Downloading playbook dependencies でモジュールをダウンロードしています。
手順

OpenShift Container Platform のインストール時より common.yaml および inventory.yaml Playbook が残っている場合があります。その場合、手順の最初の 2 つのステップを省略できます。

  1. common.yaml というローカルファイルに、以下のコンテンツを挿入します。

    例8.17 common.yaml Ansible Playbook

    - hosts: localhost
      gather_facts: no
    
      vars_files:
      - metadata.json
    
      tasks:
      - name: 'Compute resource names'
        set_fact:
          cluster_id_tag: "openshiftClusterID={{ infraID }}"
          os_network: "{{ infraID }}-network"
          os_subnet: "{{ infraID }}-nodes"
          os_router: "{{ infraID }}-external-router"
          # Port names
          os_port_api: "{{ infraID }}-api-port"
          os_port_ingress: "{{ infraID }}-ingress-port"
          os_port_bootstrap: "{{ infraID }}-bootstrap-port"
          os_port_master: "{{ infraID }}-master-port"
          os_port_worker: "{{ infraID }}-worker-port"
          # Security groups names
          os_sg_master: "{{ infraID }}-master"
          os_sg_worker: "{{ infraID }}-worker"
          # Server names
          os_bootstrap_server_name: "{{ infraID }}-bootstrap"
          os_cp_server_name: "{{ infraID }}-master"
          os_cp_server_group_name: "{{ infraID }}-master"
          os_compute_server_name: "{{ infraID }}-worker"
          # Trunk names
          os_cp_trunk_name: "{{ infraID }}-master-trunk"
          os_compute_trunk_name: "{{ infraID }}-worker-trunk"
          # Subnet pool name
          subnet_pool: "{{ infraID }}-kuryr-pod-subnetpool"
          # Service network name
          os_svc_network: "{{ infraID }}-kuryr-service-network"
          # Service subnet name
          os_svc_subnet: "{{ infraID }}-kuryr-service-subnet"
          # Ignition files
          os_bootstrap_ignition: "{{ infraID }}-bootstrap-ignition.json"
    Copy to Clipboard Toggle word wrap
  2. inventory.yaml というローカルファイルに以下のコンテンツを挿入し、独自の値に一致するように値を編集します。

    例8.18 inventory.yaml Ansible Playbook

    all:
      hosts:
        localhost:
          ansible_connection: local
          ansible_python_interpreter: "{{ansible_playbook_python}}"
    
          # User-provided values
          os_subnet_range: '10.0.0.0/16'
          os_flavor_master: 'm1.xlarge'
          os_flavor_worker: 'm1.large'
          os_image_rhcos: 'rhcos'
          os_external_network: 'external'
          # OpenShift API floating IP address
          os_api_fip: '203.0.113.23'
          # OpenShift Ingress floating IP address
          os_ingress_fip: '203.0.113.19'
          # Service subnet cidr
          svc_subnet_range: '172.30.0.0/16'
          os_svc_network_range: '172.30.0.0/15'
          # Subnet pool prefixes
          cluster_network_cidrs: '10.128.0.0/14'
          # Subnet pool prefix length
          host_prefix: '23'
          # Name of the SDN.
          # Possible values are OpenshiftSDN or Kuryr.
          os_networking_type: 'OpenshiftSDN'
    
          # Number of provisioned Control Plane nodes
          # 3 is the minimum number for a fully-functional cluster.
          os_cp_nodes_number: 3
    
          # Number of provisioned Compute nodes.
          # 3 is the minimum number for a fully-functional cluster.
          os_compute_nodes_number: 3
    Copy to Clipboard Toggle word wrap
  3. オプション: クラスターで Kuryr を使用する場合は、down-load-balancers.yaml というローカルファイルに以下のコンテンツを挿入します。

    例8.19 down-load-balancers.yaml

    # Required Python packages:
    #
    # ansible
    # openstackcli
    # openstacksdk
    
    - import_playbook: common.yaml
    
    - hosts: all
      gather_facts: no
    
      tasks:
      - name: 'Get an auth token'
        os_auth:
        register: cloud
        when: os_networking_type == "Kuryr"
    
      - name: 'List octavia versions'
        uri:
          method: GET
          headers:
            X-Auth-Token: "{{ cloud.ansible_facts.auth_token }}"
            Content-Type: 'application/json'
          url: "{{ cloud.ansible_facts.service_catalog | selectattr('name', 'match', 'octavia') | first | json_query('endpoints') | selectattr('interface', 'match', 'public') | first | json_query('url') }}/"
        register: octavia_versions
        when: os_networking_type == "Kuryr"
    
      - set_fact:
          versions: "{{ octavia_versions.json.versions | selectattr('id', 'match', 'v2.5') | map(attribute='id') | list }}"
        when: os_networking_type == "Kuryr"
    
      - name: 'List tagged loadbalancers'
        uri:
          method: GET
          headers:
            X-Auth-Token: "{{ cloud.ansible_facts.auth_token }}"
          url: "{{ cloud.ansible_facts.service_catalog | selectattr('name', 'match', 'octavia') | first | json_query('endpoints') | selectattr('interface', 'match', 'public') | first | json_query('url') }}/v2.0/lbaas/loadbalancers?tags={{cluster_id_tag}}"
        when:
        - os_networking_type == "Kuryr"
        - versions | length > 0
        register: lbs_tagged
    
      # NOTE: Kuryr creates an Octavia load balancer
      # for each service present on the cluster. Let's make
      # sure to remove the resources generated.
      - name: 'Remove the cluster load balancers'
        command:
          cmd: "openstack loadbalancer delete --cascade {{ item.id }}"
        with_items: "{{ lbs_tagged.json.loadbalancers }}"
        when:
        - os_networking_type == "Kuryr"
        - versions | length > 0
        - '"PENDING" not in item.provisioning_status'
    
      - name: 'List loadbalancers tagged on description'
        uri:
          method: GET
          headers:
            X-Auth-Token: "{{ cloud.ansible_facts.auth_token }}"
          url: "{{ cloud.ansible_facts.service_catalog | selectattr('name', 'match', 'octavia') | first | json_query('endpoints') | selectattr('interface', 'match', 'public') | first | json_query('url') }}/v2.0/lbaas/loadbalancers?description={{cluster_id_tag}}"
        when:
        - os_networking_type == "Kuryr"
        - versions | length == 0
        register: lbs_description
    
      # NOTE: Kuryr creates an Octavia load balancer
      # for each service present on the cluster. Let's make
      # sure to remove the resources generated.
      - name: 'Remove the cluster load balancers'
        command:
          cmd: "openstack loadbalancer delete --cascade {{ item.id }}"
        with_items: "{{ lbs_description.json.loadbalancers }}"
        when:
        - os_networking_type == "Kuryr"
        - versions | length == 0
        - '"PENDING" not in item.provisioning_status'
    Copy to Clipboard Toggle word wrap
  4. down-compute-nodes.yaml というローカルファイルに、以下のコンテンツを挿入します。

    例8.20 down-compute-nodes.yaml

    # Required Python packages:
    #
    # ansible
    # openstackclient
    # openstacksdk
    
    - import_playbook: common.yaml
    
    - hosts: all
      gather_facts: no
    
      tasks:
      - name: 'Remove the Compute servers'
        os_server:
          name: "{{ item.1 }}-{{ item.0 }}"
          state: absent
        with_indexed_items: "{{ [os_compute_server_name] * os_compute_nodes_number }}"
    
      - name: 'List the Compute trunks'
        command:
          cmd: "openstack network trunk list -c Name -f value"
        when: os_networking_type == "Kuryr"
        register: trunks
    
      - name: 'Remove the Compute trunks'
        command:
          cmd: "openstack network trunk delete {{ item.1 }}-{{ item.0 }}"
        when:
        - os_networking_type == "Kuryr"
        - (item.1|string + '-' + item.0|string) in trunks.stdout_lines|list
        with_indexed_items: "{{ [os_compute_trunk_name] * os_compute_nodes_number }}"
    
      - name: 'Remove the Compute ports'
        os_port:
          name: "{{ item.1 }}-{{ item.0 }}"
          state: absent
        with_indexed_items: "{{ [os_port_worker] * os_compute_nodes_number }}"
    Copy to Clipboard Toggle word wrap
  5. down-control-plane.yaml というローカルファイルに、以下のコンテンツを挿入します。

    例8.21 down-control-plane.yaml

    # Required Python packages:
    #
    # ansible
    # openstackclient
    # openstacksdk
    
    - import_playbook: common.yaml
    
    - hosts: all
      gather_facts: no
    
      tasks:
      - name: 'Remove the Control Plane servers'
        os_server:
          name: "{{ item.1 }}-{{ item.0 }}"
          state: absent
        with_indexed_items: "{{ [os_cp_server_name] * os_cp_nodes_number }}"
    
      - name: 'Remove the Control Plane server group'
        os_server_group:
          name: "{{ os_cp_server_group_name }}"
          state: absent
    
      - name: 'List the Compute trunks'
        command:
          cmd: "openstack network trunk list -c Name -f value"
        when: os_networking_type == "Kuryr"
        register: trunks
    
      - name: 'Remove the Control Plane trunks'
        command:
          cmd: "openstack network trunk delete {{ item.1 }}-{{ item.0 }}"
        when:
        - os_networking_type == "Kuryr"
        - (item.1|string + '-' + item.0|string) in trunks.stdout_lines|list
        with_indexed_items: "{{ [os_cp_trunk_name] * os_cp_nodes_number }}"
    
      - name: 'Remove the Control Plane ports'
        os_port:
          name: "{{ item.1 }}-{{ item.0 }}"
          state: absent
        with_indexed_items: "{{ [os_port_master] * os_cp_nodes_number }}"
    Copy to Clipboard Toggle word wrap
  6. down-bootstrap.yaml というローカルファイルに、以下のコンテンツを挿入します。

    例8.22 down-bootstrap.yaml

    # Required Python packages:
    #
    # ansible
    # openstacksdk
    
    - import_playbook: common.yaml
    
    - hosts: all
      gather_facts: no
    
      tasks:
      - name: 'Remove the bootstrap server'
        os_server:
          name: "{{ os_bootstrap_server_name }}"
          state: absent
          delete_fip: yes
    
      - name: 'Remove the bootstrap server port'
        os_port:
          name: "{{ os_port_bootstrap }}"
          state: absent
    Copy to Clipboard Toggle word wrap
  7. down-network.yaml というローカルファイルに、以下のコンテンツを挿入します。

    例8.23 down-network.yaml

    # Required Python packages:
    #
    # ansible
    # openstackclient
    # openstacksdk
    
    - import_playbook: common.yaml
    
    - hosts: all
      gather_facts: no
    
      tasks:
      - name: 'List ports attatched to router'
        command:
          cmd: "openstack port list --device-owner=network:router_interface --tags {{ cluster_id_tag }} -f value -c id"
        register: router_ports
    
      - name: 'Remove the ports from router'
        command:
          cmd: "openstack router remove port {{ os_router }} {{ item.1}}"
        with_indexed_items: "{{ router_ports.stdout_lines }}"
    
      - name: 'List ha ports attached to router'
        command:
          cmd: "openstack port list --device-owner=network:ha_router_replicated_interface --tags {{ cluster_id_tag }} -f value -c id"
        register: ha_router_ports
    
      - name: 'Remove the ha ports from router'
        command:
          cmd: "openstack router remove port {{ os_router }} {{ item.1}}"
        with_indexed_items: "{{ ha_router_ports.stdout_lines }}"
    
      - name: 'List ports'
        command:
          cmd: "openstack port list --tags {{ cluster_id_tag }} -f value -c id "
        register: ports
    
      - name: 'Remove the cluster ports'
        command:
          cmd: "openstack port delete {{ item.1}}"
        with_indexed_items: "{{ ports.stdout_lines }}"
    
      - name: 'Remove the cluster router'
        os_router:
          name: "{{ os_router }}"
          state: absent
    
      - name: 'List cluster networks'
        command:
          cmd: "openstack network list --tags {{ cluster_id_tag }} -f value -c Name"
        register: networks
    
      - name: 'Remove the cluster networks'
        os_network:
          name: "{{ item.1}}"
          state: absent
        with_indexed_items: "{{ networks.stdout_lines }}"
    
      - name: 'List the cluster subnet pool'
        command:
          cmd: "openstack subnet pool list --name {{ subnet_pool }}"
        when: os_networking_type == "Kuryr"
        register: pods_subnet_pool
    
      - name: 'Remove the cluster subnet pool'
        command:
          cmd: "openstack subnet pool delete {{ subnet_pool }}"
        when:
        - os_networking_type == "Kuryr"
        - pods_subnet_pool.stdout != ""
    Copy to Clipboard Toggle word wrap
  8. down-security-groups.yaml というローカルファイルに、以下のコンテンツを挿入します。

    例8.24 down-security-groups.yaml

    # Required Python packages:
    #
    # ansible
    # openstackclient
    # openstacksdk
    
    - import_playbook: common.yaml
    
    - hosts: all
      gather_facts: no
    
      tasks:
      - name: 'List security groups'
        command:
          cmd: "openstack security group list --tags {{ cluster_id_tag }} -f value -c ID"
        register: security_groups
    
      - name: 'Remove the cluster security groups'
        command:
          cmd: "openstack security group delete {{ item.1 }}"
        with_indexed_items: "{{ security_groups.stdout_lines }}"
    Copy to Clipboard Toggle word wrap
  9. コマンドラインで、作成した Playbook を実行します。

    $ ansible-playbook -i inventory.yaml  \
    	down-bootstrap.yaml      \
    	down-control-plane.yaml  \
    	down-compute-nodes.yaml  \
    	down-load-balancers.yaml \
    	down-network.yaml        \
    	down-security-groups.yaml
    Copy to Clipboard Toggle word wrap
  10. OpenShift Container Platform インストールに対して加えた DNS レコードの変更を削除します。

OpenShift Container Platform はお使いのインフラストラクチャーから削除されます。

トップに戻る
Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

Red Hat ドキュメントについて

Red Hat をお使いのお客様が、信頼できるコンテンツが含まれている製品やサービスを活用することで、イノベーションを行い、目標を達成できるようにします。 最新の更新を見る.

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

Theme

© 2025 Red Hat