Chapter 2. Customizing networks for Red Hat OpenStack Services on OpenShift
You can add routes to the Red Hat OpenShift Container Platform (RHOCP) network configuration you prepared for your Red Hat OpenStack Services on OpenShift (RHOSO) environment on your RHOCP cluster.
2.1. Adding routes to the RHOCP networks Copy linkLink copied to clipboard!
To add routes to the Red Hat OpenShift Container Platform (RHOCP) networks, you add the routes field to the NodeNetworkConfigurationPolicy (nncp), NetworkAttachmentDefinition (net-attach-def), and NetConfig custom resources.
Prerequisites
- You have prepared the RHOCP networks. For more information, see Preparing networks for Red Hat OpenStack Services on OpenShift in the Deploying RHOSO guide.
Procedure
-
Open the
NodeNetworkConfigurationPolicy(nncp) CR file on your workstation, for example,openstack-nncp.yaml. Add the
routesfield to thenncpCR, and add configuration for each route. The following example adds routes to thenncpCR that configures theenp6s0interface for worker node 1,osp-enp6s0-worker-1:apiVersion: 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/24Update the
nncpCR in the cluster:$ oc apply -f openstack-nncp.yaml-
Open the
NetworkAttachmentDefinition(net-attach-def) CR file on your workstation, for example, o`penstack-net-attach-def.yaml`. Add the
routesfield to theconfigfield for each isolated network, and add configuration for each route. The following example addsroutesto thenet-attach-defCR for thetenantnetwork: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" } ] } }Update the
NetworkAttachmentDefinitionCR in the cluster:$ oc apply -f openstack-net-attach-def.yaml-
Open the
NetConfigCR file on your workstation, for example,openstack_netconfig.yaml. Add the
routesfield to thenetworksfield for each isolated network. The following example addsroutesto the three subnets of thectlplanenetwork: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.1Update the data plane network:
$ oc apply -f openstack_netconfig.yaml -n openstack