搜索

12.5.23. 创建在 SR-IOV 网络中运行的计算机器

download PDF

启动 control plane 后,创建在"为计算机器创建 SR-IOV 网络"中创建的 SR-IOV 网络上运行的计算机器。

先决条件

  • 您下载了"下载 playbook 依赖项"中的模块。
  • 下载了"下载安装 playbook"中的 playbook。
  • 安装程序创建的 metadata.yaml 文件与 Ansible playbook 位于同一个目录中。
  • control plane 处于活跃状态。
  • 您创建了 radiouplink SR-IOV 网络,如"为计算机器创建 SR-IOV 网络"中所述。

流程

  1. 在命令行中,将工作目录改为 inventory.yamlcommon.yaml 文件的位置。
  2. 使用 additionalNetworks 参数在 inventory.yaml 文件末尾添加 radiouplink网络:

    ....
    # If this value is non-empty, the corresponding floating IP will be
    # attached to the bootstrap machine. This is needed for collecting logs
    # in case of install failure.
        os_bootstrap_fip: '203.0.113.20'
    
        additionalNetworks:
        - id: radio
          count: 4 1
          type: direct
          port_security_enabled: no
        - id: uplink
          count: 4 2
          type: direct
          port_security_enabled: no
    1 2
    count 参数定义附加到每个 worker 节点的 SR-IOV 虚拟功能(VF)的数量。在这种情况下,每个网络都有四个 VF。
  3. compute-nodes.yaml 文件的内容替换为以下文本:

    例 12.1. compute-nodes.yaml

    - import_playbook: common.yaml
    
    - hosts: all
      gather_facts: no
    
      vars:
        worker_list: []
        port_name_list: []
        nic_list: []
    
      tasks:
      # Create the SDN/primary port for each worker node
      - name: 'Create the Compute ports'
        os_port:
          name: "{{ item.1 }}-{{ item.0 }}"
          network: "{{ os_network }}"
          security_groups:
          - "{{ os_sg_worker }}"
          allowed_address_pairs:
          - ip_address: "{{ os_ingressVIP }}"
        with_indexed_items: "{{ [os_port_worker] * os_compute_nodes_number }}"
        register: ports
    
      # Tag each SDN/primary port with cluster name
      - name: 'Set Compute ports tag'
        command:
          cmd: "openstack port set --tag {{ cluster_id_tag }} {{ item.1 }}-{{ item.0 }}"
        with_indexed_items: "{{ [os_port_worker] * os_compute_nodes_number }}"
    
      - name: 'List the Compute Trunks'
        command:
          cmd: "openstack network trunk list"
        when: os_networking_type == "Kuryr"
        register: compute_trunks
    
      - name: 'Create the Compute trunks'
        command:
          cmd: "openstack network trunk create --parent-port {{ item.1.id }} {{ os_compute_trunk_name }}-{{ item.0 }}"
        with_indexed_items: "{{ ports.results }}"
        when:
        - os_networking_type == "Kuryr"
        - "os_compute_trunk_name|string not in compute_trunks.stdout"
    
      - name: ‘Call additional-port processing’
        include_tasks: additional-ports.yaml
    
      # Create additional ports in OpenStack
      - name: ‘Create additionalNetworks ports’
        os_port:
          name:  "{{ item.0 }}-{{ item.1.name }}"
          vnic_type: "{{ item.1.type }}"
          network: "{{ item.1.uuid }}"
          port_security_enabled: "{{ item.1.port_security_enabled|default(omit) }}"
          no_security_groups: "{{ 'true' if item.1.security_groups is not defined else omit }}"
          security_groups: "{{ item.1.security_groups | default(omit) }}"
        with_nested:
          - "{{ worker_list }}"
          - "{{ port_name_list }}"
    
      # Tag the ports with the cluster info
      - name: 'Set additionalNetworks ports tag'
        command:
          cmd: "openstack port set --tag {{ cluster_id_tag }} {{ item.0 }}-{{ item.1.name }}"
        with_nested:
          - "{{ worker_list }}"
          - "{{ port_name_list }}"
    
      # Build the nic list to use for server create
      - name: Build nic list
        set_fact:
          nic_list: "{{ nic_list | default([]) + [ item.name ] }}"
        with_items: "{{ port_name_list }}"
    
      # Create the servers
      - name: 'Create the Compute servers'
        vars:
          worker_nics: "{{ [ item.1 ] | product(nic_list) | map('join','-') | map('regex_replace', '(.*)', 'port-name=\\1') | list }}"
        os_server:
          name: "{{ item.1 }}"
          image: "{{ os_image_rhcos }}"
          flavor: "{{ os_flavor_worker }}"
          auto_ip: no
          userdata: "{{ lookup('file', 'worker.ign') | string }}"
          security_groups: []
          nics:  "{{ [ 'port-name=' + os_port_worker + '-' + item.0|string ] + worker_nics }}"
          config_drive: yes
        with_indexed_items: "{{ worker_list }}"
  4. 将以下内容插入到名为 additional-ports.yaml 的本地文件中:

    例 12.2. additional-ports.yaml

    # Build a list of worker nodes with indexes
    - name: ‘Build worker list’
      set_fact:
        worker_list: "{{ worker_list | default([]) + [ item.1 + '-' + item.0 | string ] }}"
      with_indexed_items: "{{ [ os_compute_server_name ] * os_compute_nodes_number }}"
    
    # Ensure that each network specified in additionalNetworks exists
    - name: ‘Verify additionalNetworks’
      os_networks_info:
        name: "{{ item.id }}"
      with_items: "{{ additionalNetworks }}"
      register: network_info
    
    # Expand additionalNetworks by the count parameter in each network definition
    - name: ‘Build port and port index list for additionalNetworks’
      set_fact:
        port_list: "{{ port_list | default([]) + [ {
                        'net_name' : item.1.id,
                        'uuid' : network_info.results[item.0].openstack_networks[0].id,
                        'type' : item.1.type|default('normal'),
                        'security_groups' : item.1.security_groups|default(omit),
                        'port_security_enabled' : item.1.port_security_enabled|default(omit)
                        } ] * item.1.count|default(1) }}"
        index_list: "{{ index_list | default([]) + range(item.1.count|default(1)) | list }}"
      with_indexed_items: "{{ additionalNetworks }}"
    
    # Calculate and save the name of the port
    # The format of the name is cluster_name-worker-workerID-networkUUID(partial)-count
    # i.e. fdp-nz995-worker-1-99bcd111-1
    - name: ‘Calculate port name’
      set_fact:
        port_name_list: "{{ port_name_list | default([]) + [ item.1 | combine( {'name' : item.1.uuid | regex_search('([^-]+)') + '-' + index_list[item.0]|string } ) ] }}"
      with_indexed_items: "{{ port_list }}"
      when: port_list is defined
  5. 在命令行中运行 compute-nodes.yaml playbook:

    $ ansible-playbook -i inventory.yaml compute-nodes.yaml
Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.