第 2 章 在 OpenShift 上为 Red Hat OpenStack Services 自定义网络
您可以将路由添加到 Red Hat OpenShift Container Platform (RHOCP)网络配置中,您可以在 RHOCP 集群上为 Red Hat OpenStack Services (RHOSO)环境做好准备。
2.1. 在 RHOCP 网络中添加路由 复制链接链接已复制到粘贴板!
要为 Red Hat OpenShift Container Platform (RHOCP)网络添加路由,您可以在 NodeNetworkConfigurationPolicy (nncp)、NetworkAttachmentDefinition (net-attach-def)和 NetConfig 自定义资源中添加 routes 字段。
先决条件
- 您已准备了 RHOCP 网络。如需更多信息,请参阅 部署 RHOSO 指南中的 为 OpenShift 上的 Red Hat OpenStack Services 准备网络。
流程
-
在工作站上打开
NodeNetworkConfigurationPolicy(nncp) CR 文件,例如openstack-nncp.yaml。 将
routes字段添加到nncpCR 中,并添加每个路由的配置。以下示例为nncpCR 添加路由,为 worker 节点 1,osp-配置 enp6s0 接口:enp6s0-worker-1apiVersion: nmstate.io/v1 kind: NodeNetworkConfigurationPolicy metadata: name: osp-enp6s0-worker-1 spec: desiredState: interfaces: ... routes: config: - destination: 192.168.123.0/24 metric: 150 next-hop-address: 192.168.122.1 next-hop-interface: ospbr - destination: 192.168.124.0/24 metric: 150 next-hop-address: 192.168.122.1 next-hop-interface: ospbr - destination: 172.17.1.0/24 metric: 150 next-hop-address: 172.17.0.1 next-hop-interface: internalapi - destination: 172.17.2.0/24 metric: 150 next-hop-address: 172.17.0.1 next-hop-interface: internalapi - destination: 172.18.1.0/24更新集群中的
nncpCR:$ oc apply -f openstack-nncp.yaml-
在工作站上打开
NetworkAttachmentDefinition(net-attach-def) CR 文件,例如 o'penstack-net-attach-def.yaml'。 将
routes字段添加到每个隔离的网络的config字段中,再为每个路由添加配置。以下示例将路由添加到租户网络的net-attach-defCR 中:apiVersion: k8s.cni.cncf.io/v1 kind: NetworkAttachmentDefinition metadata: name: tenant namespace: openstack spec: config: | { "cniVersion": "0.3.1", "name": "tenant", "type": "macvlan", "master": "tenant", "ipam": { "type": "whereabouts", "range": "172.19.0.0/24", "range_start": "172.19.0.30", "range_end": "172.19.0.70", "routes": [ { "dst": "172.19.1.0/24", "gw": "172.19.0.1" }, { "dst": "172.19.2.0/24", "gw": "172.19.0.1" } ] } }更新集群中的
NetworkAttachmentDefinitionCR:$ oc apply -f openstack-net-attach-def.yaml-
在工作站上打开
NetConfigCR 文件,如openstack_netconfig.yaml。 将
routes字段添加到每个隔离的网络的networks字段中。以下示例将路由添加到ctlplane网络的三个子网中:apiVersion: network.openstack.org/v1beta1 kind: NetConfig metadata: name: openstacknetconfig namespace: openstack spec: networks: - name: ctlplane dnsDomain: ctlplane.openstack.lab 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 routes: - destination: 192.168.123.0/24 nexthop: 192.168.122.1 - destination: 192.168.124.0/24 nexthop: 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 routes: - destination: 192.168.122.0/24 nexthop: 192.168.123.1 - destination: 192.168.124.0/24 nexthop: 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 routes: - destination: 192.168.122.0/24 nexthop: 192.168.124.1 - destination: 192.168.123.0/24 nexthop: 192.168.124.1更新 data plane 网络:
$ oc apply -f openstack_netconfig.yaml -n openstack