4.4. 为 BGP 创建数据平面网络


要创建 data plane 网络,请定义一个 NetConfig 自定义资源(CR)并为 data plane 网络指定所有子网。您必须为您的数据平面至少定义一个 control plane 网络。您还可以定义 VLAN 网络,为可组合网络创建网络隔离,如 InternalAPIStorageExternal。每个网络定义必须包含 IP 地址分配。

提示

使用以下命令查看 NetConfig CRD 定义和规格模式:

$ oc describe crd netconfig

$ oc explain netconfig.spec
Copy to Clipboard Toggle word wrap

流程

  1. 在工作站上创建一个名为 netconfig_bgp.yaml 的文件。
  2. 将以下配置添加到 netconfig_bgp.yaml 以创建 NetConfig CR:

    apiVersion: network.openstack.org/v1beta1
    kind: NetConfig
    metadata:
      name: bgp-netconfig
      namespace: openstack
    Copy to Clipboard Toggle word wrap
  3. netconfig_bgp.yaml 文件中,为每个 data plane 网络定义拓扑。要在 OpenShift (RHOSO)网络中使用默认的 Red Hat OpenStack Services,您必须为每个网络定义一个规格。有关默认 RHOSO 网络的信息,请参阅 BGP 的 OpenShift 网络上的默认 Red Hat OpenStack Services。以下示例为数据平面创建隔离网络:

    apiVersion: network.openstack.org/v1beta1
    kind: NetConfig
    metadata:
      name: bgp-netconfig
      namespace: openstack
    spec:
      networks:
      - name: ctlplane 
    1
    
        dnsDomain: ctlplane.example.com
        serviceNetwork: ctlplane
        mtu: 1500
        subnets: 
    2
    
        - name: subnet1 
    3
    
          allocationRanges: 
    4
    
          - end: 192.168.122.120
            start: 192.168.122.100
          - end: 192.168.122.200
            start: 192.168.122.150
          cidr: 192.168.122.0/24
          gateway: 192.168.122.1
        - name: subnet2
          allocationRanges:
          - end: 192.168.123.120
            start: 192.168.123.100
          - end: 192.168.123.200
            start: 192.168.123.150
          cidr: 192.168.123.0/24
          gateway: 192.168.123.1
        - name: subnet3
          allocationRanges:
          - end: 192.168.124.120
            start: 192.168.124.100
          - end: 192.168.124.200
            start: 192.168.124.150
          cidr: 192.168.124.0/24
          gateway: 192.168.124.1
      - name: internalapi
        dnsDomain: internalapi.example.com
        serviceNetwork: internalapi
        mtu: 1500
        subnets:
        - name: subnet1
          allocationRanges:
          - end: 172.17.0.250
            start: 172.17.0.100
          cidr: 172.17.0.0/24
        vlan: 20 
    5
    
      - name: external
        dnsDomain: external.example.com
        mtu: 1500
        subnets:
        - name: subnet1
          allocationRanges:
          - end: 192.168.32.250
            start: 192.168.32.130
          cidr: 192.168.32.0/20
        vlan: 99
      - name: storage
        dnsDomain: storage.example.com
        mtu: 1500
        subnets:
        - name: subnet1
          allocationRanges:
          - end: 172.18.0.250
            start: 172.18.0.100
        cidr: 172.18.0.0/24
        vlan: 21
      - name: tenant
        dnsDomain: tenant.example.com
        mtu: 1500
        subnets:
        - name: subnet1
          allocationRanges:
          - end: 172.19.0.250
            start: 172.19.0.100
          cidr: 172.19.0.0/24
        vlan: 22
    Copy to Clipboard Toggle word wrap
    1
    网络的名称,如 CtlPlane
    2
    IPv4 子网规格。
    3
    子网的名称,如 subnet1
    4
    NetConfig allocationRangeallocationRange 不得与 MetalLB IPAddressPool 范围和 IP 地址池范围重叠。
    5
    网络 VLAN。有关默认 RHOSO 网络的信息,请参阅 BGP 的 OpenShift 网络上的默认 Red Hat OpenStack Services
  4. netconfig_bgp.yaml 文件中,定义在每个区内建立连接的网络接口。以下示例定义了两个网络接口,eth2bgpnet0bgpnet1 用于 'eth3,每个区都有一个子网:

      - name: bgpnet0 
    1
    
        dnsDomain: bgpnet0.example.com
        serviceNetwork: bgpnet0
        mtu: 1500
        subnets:
        - name: subnet0
          allocationRanges:
          - end: 100.64.0.36
            start: 100.64.0.1
          cidr: 100.64.0.0/24
          gateway: 100.64.0.1
          routes:
          - destination: 0.0.0.0/0
            nexthop: 100.64.0.1
        - name: subnet1
          allocationRanges:
          - end: 100.64.1.36
            start: 100.64.1.1
          cidr: 100.64.1.0/24
          gateway: 100.64.1.1
          routes:
          - destination: 0.0.0.0/0
            nexthop: 100.64.1.1
        - name: subnet2
          allocationRanges:
          - end: 100.64.2.36
            start: 100.64.2.1
          cidr: 100.64.2.0/24
          gateway: 100.64.2.1
          routes:
          - destination: 0.0.0.0/0
            nexthop: 100.64.2.1
      - name: bgpnet1 
    2
    
        dnsDomain: bgpnet1.example.com
        serviceNetwork: bgpnet1
        mtu: 1500
        subnets:
        - name: subnet0
          allocationRanges:
          - end: 100.65.0.36
            start: 100.65.0.1
          cidr: 100.65.0.0/24
          gateway: 100.65.0.1
          routes:
          - destination: 0.0.0.0/0
            nexthop: 100.65.0.1
        - name: subnet1
          allocationRanges:
          - end: 100.65.1.36
            start: 100.65.1.1
          cidr: 100.65.1.0/24
          gateway: 100.65.1.1
          routes:
          - destination: 0.0.0.0/0
            nexthop: 100.65.1.1
        - name: subnet2
          allocationRanges:
          - end: 100.65.2.36
            start: 100.65.2.1
          cidr: 100.65.2.0/24
          gateway: 100.65.2.1
          routes:
          - destination: 0.0.0.0/0
            nexthop: 100.65.2.1
    Copy to Clipboard Toggle word wrap
    1
    bgpnet0 是 data plane 节点用来与其 BGP peer 通信的网络。
    2
    bgpnet1 是 data plane 节点用来与其 BGP peer 通信的网络。
  5. netconfig_bgp.yaml 文件中,配置 loopback 接口 bgpmainnet 的 IP 地址,供每个节点用来相互通信:

      - name: bgpmainnet
        dnsDomain: bgpmainnet.example.com
        serviceNetwork: bgpmainnet
        mtu: 1500
        subnets:
        - name: subnet0
          allocationRanges:
          - end: 99.99.0.36
            start: 99.99.0.2
          cidr: 99.99.0.0/24
        - name: subnet1
          allocationRanges:
          - end: 99.99.1.36
            start: 99.99.1.2
          cidr: 99.99.1.0/24
        - name: subnet2
          allocationRanges:
          - end: 99.99.2.36
            start: 99.99.2.2
          cidr: 99.99.2.0/24
    Copy to Clipboard Toggle word wrap
  6. 保存 ' netconfig_bgp.yaml' 定义文件。
  7. 创建 data plane 网络:

    $ oc create -f  netconfig_bgp.yaml -n openstack
    Copy to Clipboard Toggle word wrap
  8. 创建名为 bgpconfig.ymlBGPConfiguration CR 文件,以通过 BGP 声明 pod 的 IP 地址:

    apiVersion: network.openstack.org/v1beta1
    kind: BGPConfiguration
    metadata:
      name: bgpconfiguration
      namespace: openstack
    spec: {}
    Copy to Clipboard Toggle word wrap
  9. 创建 BGPConfiguration CR,为每个 pod 创建所需的 FRR 配置:

    $ oc create -f bgpconfig.yml
    Copy to Clipboard Toggle word wrap

验证

  1. 验证是否已创建 data plane 网络:

    $ oc get netconfig/openstacknetconfig -n openstack
    Copy to Clipboard Toggle word wrap

    如果您看到错误,请检查底层 network-attach-definition 和节点网络配置策略:

    $ oc get network-attachment-definitions -n openstack
    $ oc get nncp
    Copy to Clipboard Toggle word wrap
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

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

让开源更具包容性

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

關於紅帽

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

Theme

© 2025 Red Hat