4.4. 为 BGP 创建数据平面网络
要创建 data plane 网络,请定义一个 NetConfig 自定义资源(CR)并为 data plane 网络指定所有子网。您必须为您的数据平面至少定义一个 control plane 网络。您还可以定义 VLAN 网络,为可组合网络创建网络隔离,如 InternalAPI、Storage 和 External。每个网络定义必须包含 IP 地址分配。
使用以下命令查看 NetConfig CRD 定义和规格模式:
$ oc describe crd netconfig
$ oc explain netconfig.spec
流程
-
在工作站上创建一个名为
netconfig_bgp.yaml的文件。 将以下配置添加到
netconfig_bgp.yaml以创建NetConfigCR:apiVersion: network.openstack.org/v1beta1 kind: NetConfig metadata: name: bgp-netconfig namespace: openstack在
netconfig_bgp.yaml文件中,为每个 data plane 网络定义拓扑。要在 OpenShift (RHOSO)网络中使用默认的 Red Hat OpenStack Services,您必须为每个网络定义一个规格。有关默认 RHOSO 网络的信息,请参阅 BGP 的 OpenShift 网络上的默认 Red Hat OpenStack Services。以下示例为数据平面创建隔离网络:注意此步骤中提供的示例及后续步骤中仅包含 IPv4 地址。但是,RHOSO 还支持 IPv6 地址。
apiVersion: network.openstack.org/v1beta1 kind: NetConfig metadata: name: bgp-netconfig namespace: openstack spec: networks: - name: ctlplane dnsDomain: ctlplane.example.com serviceNetwork: ctlplane mtu: 1500 subnets: - name: subnet1 allocationRanges: - 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 - 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-
spec.networks.name:网络的名称,如CtlPlane。 -
spec.networks.subnets:IPv4 子网规格。 -
spec.networks.subnets.name:子网的名称,如subnet1。 -
spec.networks.subnets.allocationRanges:NetConfigallocationRange.allocationRange不得与 MetalLBIPAddressPool范围和 IP 地址池范围重叠。 -
spec.networks.subnets.vlan:网络 VLAN。有关默认 RHOSO 网络的信息,请参阅 BGP 的 OpenShift 网络上的默认 Red Hat OpenStack Services。
-
在
netconfig_bgp.yaml文件中,定义在每个区内建立连接的网络接口。以下示例定义了两个网络接口,eth2的bgpnet0和bgpnet1用于 'eth3,每个区都有一个子网:- name: bgpnet0 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 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-
name: bgpnet0:data plane 节点用来与其 BGP peer 通信的网络。 -
name: bgpnet1: data plane 节点用来与其 BGP peer 通信的网络。
-
在
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- 保存 ' netconfig_bgp.yaml' 定义文件。
创建 data plane 网络:
$ oc create -f netconfig_bgp.yaml -n openstack创建名为
bgpconfig.yml的BGPConfigurationCR 文件,以通过 BGP 声明 pod 的 IP 地址:apiVersion: network.openstack.org/v1beta1 kind: BGPConfiguration metadata: name: bgpconfiguration namespace: openstack spec: {}创建
BGPConfigurationCR,为每个 pod 创建所需的 FRR 配置:$ oc create -f bgpconfig.yml
验证
验证是否已创建 data plane 网络:
$ oc get netconfig/openstacknetconfig -n openstack如果您看到错误,请检查底层
network-attach-definition和节点网络配置策略:$ oc get network-attachment-definitions -n openstack $ oc get nncp