配置裸机调配的 Networking 服务

您需要配置 Networking 服务,以便裸机服务器能够与 Networking 服务通信,以进行 DHCP、PXE/HTTP 启动和其他需求。本节介绍为裸机调配配置单个扁平网络。在更高级的配置中,我们通常将节点进行部署的网络称为调配网络,因为成功操作所需的底层资源必须可用才能进行调配。

警告

本文档适用于使用 OVS 与 Neutron 以及 neutron-dhcp-agent 的场景。可以使用 OVN 与 neutron-dhcp-agent 配合使用,并且根据 OVN 和 Neutron 的版本,可以使用 OVN 自己的 IPv4 客户端 DHCP 服务,但这被认为是一个高级主题,我们鼓励有兴趣使用 OVN 的操作员在尝试使用此类配置之前,充分了解其功能和状态。请参阅 使用 OVN 网络 以获取更多详细信息。

建议使用 baremetal ML2 机制驱动程序和 L2 代理,以实现与 Networking 服务的正确集成。有关安装和配置 baremetal 机制驱动程序和 L2 代理的文档,请访问 此处

对于使用 路由网络,需要 baremetal ML2 组件。

注意

使用 baremetal ML2 组件时,Networking 服务中的端口状态将为:DOWN,binding_vif_type:binding_failed。在引入 baremetal ML2 集成之前,Bare Metal 服务 flat 网络接口端口一直处于这种状态。对于非路由网络,即使 Networking 服务中存在这种端口绑定状态,裸机服务器仍然可以部署并正常运行。

您还需要向 Bare Metal 服务提供正在调配的每个节点的 MAC 地址;Bare Metal 服务将依次将此信息传递给 Networking 服务,以进行 DHCP 和 PXE 启动配置。示例请参见 使用 Ironic 注册硬件 部分。

  1. 在 Networking 服务中安装 networking-baremetal ML2 机制驱动程序和 L2 代理。

  2. 编辑 /etc/neutron/plugins/ml2/ml2_conf.ini 并修改以下内容

    [ml2]
    type_drivers = flat
    tenant_network_types = flat
    mechanism_drivers = openvswitch,baremetal
    
    [ml2_type_flat]
    flat_networks = physnet1
    
    [securitygroup]
    firewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver
    enable_security_group = True
    
    [ovs]
    bridge_mappings = physnet1:br-eth2
    # Replace eth2 with the interface on the neutron node which you
    # are using to connect to the bare metal server
    
  3. 重新启动 neutron-server 服务,以加载新的配置。

  4. 创建并编辑 /etc/neutron/plugins/ml2/ironic_neutron_agent.ini 并添加所需的配置。例如

    [ironic]
    project_domain_name = Default
    project_name = service
    user_domain_name = Default
    password = password
    username = ironic
    auth_url = http://identity-server.example.com/identity
    auth_type = password
    region_name = RegionOne
    
  5. 确保已启动 ironic-neutron-agent 服务。

  6. 如果 neutron-openvswitch-agent 使用 ovs_neutron_plugin.ini 作为输入配置文件,请编辑 ovs_neutron_plugin.ini 以通过添加上一步描述的 [ovs] 部分来配置桥接映射,然后重新启动 neutron-openvswitch-agent。

  7. 将集成桥接添加到 Open vSwitch

    $ ovs-vsctl add-br br-int
    
  8. 创建 br-eth2 网络桥接,以处理 OpenStack 服务(和 Bare Metal 服务)与使用 eth2 的裸机节点之间的通信。将 eth2 替换为用于连接到 Bare Metal 服务的网络节点上的接口

    $ ovs-vsctl add-br br-eth2
    $ ovs-vsctl add-port br-eth2 eth2
    
  9. 重新启动 Open vSwitch 代理

    # service neutron-plugin-openvswitch-agent restart
    
  10. 在重新启动 Networking 服务 Open vSwitch 代理后,桥接 br-int 和 br-eth2 之间的 veth 对会自动创建。

    遵循上述步骤后,您的 Open vSwitch 桥接应该如下所示

    $ ovs-vsctl show
    
        Bridge br-int
            fail_mode: secure
            Port "int-br-eth2"
                Interface "int-br-eth2"
                    type: patch
                    options: {peer="phy-br-eth2"}
            Port br-int
                Interface br-int
                    type: internal
        Bridge "br-eth2"
            Port "phy-br-eth2"
                Interface "phy-br-eth2"
                    type: patch
                    options: {peer="int-br-eth2"}
            Port "eth2"
                Interface "eth2"
            Port "br-eth2"
                Interface "br-eth2"
                    type: internal
        ovs_version: "2.3.0"
    
  11. 在您将要启动实例的扁平网络上创建网络

    $ openstack network create --project $TENANT_ID sharednet1 --share \
         --provider-network-type flat --provider-physical-network physnet1
    
  12. 在新创建的网络上创建子网

    $ openstack subnet create $SUBNET_NAME --network sharednet1 \
      --subnet-range $NETWORK_CIDR --ip-version 4 --gateway $GATEWAY_IP \
      --allocation-pool start=$START_IP,end=$END_IP --dhcp