|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * networking/bgp-routing/about-bgp-routing.adoc |
| 4 | + |
| 5 | +:_mod-docs-content-type: CONCEPT |
| 6 | +[id="nw-bgp-examples_{context}"] |
| 7 | += Examples advertising pod IP addresses with BGP |
| 8 | + |
| 9 | +The following examples describe several different configurations for advertising pod IP addresses with BGP. The external network border router has the `172.18.0.5` IP address. |
| 10 | + |
| 11 | +Each example relies upon the following `FRRConfiguration` object: |
| 12 | + |
| 13 | +.`FRRConfiguration` CR |
| 14 | +[source,yaml] |
| 15 | +---- |
| 16 | +apiVersion: frrk8s.metallb.io/v1beta1 |
| 17 | +kind: FRRConfiguration |
| 18 | +metadata: |
| 19 | + name: receive-all |
| 20 | + namespace: openshift-frr-k8s |
| 21 | +spec: |
| 22 | + bgp: |
| 23 | + routers: |
| 24 | + - asn: 64512 |
| 25 | + neighbors: |
| 26 | + - address: 172.18.0.5 |
| 27 | + asn: 64512 |
| 28 | + disableMP: true |
| 29 | + toReceive: |
| 30 | + allowed: |
| 31 | + mode: filtered |
| 32 | +---- |
| 33 | + |
| 34 | +The OVN-Kubernetes controller checks that the `RouteAdvertisements` CR selected nodes are a subset of the nodes selected by the `RouteAdvertisements` CR selected FRRConfigurations. |
| 35 | + |
| 36 | +For these examples a user-defined network named `blue` exists with a network of `10.0.0.0/16` and a matching VRF device exists in the Linux host. The slice of this supernet allocated to nodes with the `kubernetes.io/hostname: ovn-worker` label is `10.0.1.0/24`. |
| 37 | + |
| 38 | +[id="advertising-pod-ips-from-a-user-defined-network-over-bgp_{context}"] |
| 39 | +== Advertising pod IPs from a user-defined network over BGP |
| 40 | + |
| 41 | +In this scenario, the blue user-defined network is exposed to the external network so that the attached pods have IP addresses that are reachable from the external network. The user-defined networks are each attached to a different VRF device: |
| 42 | + |
| 43 | +Red user-defined network:: |
| 44 | +- A VRF named `mp0-red` |
| 45 | +- A subnet of `10.0.0.0/24` |
| 46 | + |
| 47 | +Blue user-defined network:: |
| 48 | +- A VRF named `mp0-blue` |
| 49 | +- A subnet of `10.0.1.0/24` |
| 50 | + |
| 51 | +In this configuration, two separate user-defined networks are defined. The red network covers the `10.0.0.0/24` subnet and the blue network covers the `10.0.1.0/24` subnet. |
| 52 | + |
| 53 | +The following `RouteAdvertisements` CR describes the configuration for the blue tenant: |
| 54 | + |
| 55 | +.`RouteAdvertisements` CR for the blue tenant |
| 56 | +[source,yaml] |
| 57 | +---- |
| 58 | +apiVersion: k8s.ovn.org/v1 |
| 59 | +kind: RouteAdvertisements |
| 60 | +metadata: |
| 61 | + name: default |
| 62 | +spec: |
| 63 | + advertisements: |
| 64 | + - PodNetwork |
| 65 | + networkSelector: |
| 66 | + matchLabels: |
| 67 | + k8s.ovn.org/metadata.name: blue |
| 68 | + frrConfigurationSelector: |
| 69 | + matchLabels: |
| 70 | + routeAdvertisements: receive-all |
| 71 | +---- |
| 72 | + |
| 73 | +When the OVN-Kubernetes controller sees this `RouteAdvertisements` CR, it generates a `FRRConfiguration` object that configures the FRR daemon to advertise the routes. |
| 74 | + |
| 75 | +.`FRRConfiguration` CR generated by OVN-Kubernetes |
| 76 | +[source,yaml] |
| 77 | +---- |
| 78 | +apiVersion: frrk8s.metallb.io/v1beta1 |
| 79 | +kind: FRRConfiguration |
| 80 | +metadata: |
| 81 | + name: ovnk-generated-abcdef |
| 82 | + namespace: openshift-frr-k8s |
| 83 | +spec: |
| 84 | + bgp: |
| 85 | + routers: |
| 86 | + - asn: 64512 |
| 87 | + vrf: blue |
| 88 | + imports: |
| 89 | + - vrf: default |
| 90 | + - asn: 64512 |
| 91 | + neighbors: |
| 92 | + - address: 172.18.0.5 |
| 93 | + asn: 64512 |
| 94 | + toReceive: |
| 95 | + allowed: |
| 96 | + prefixes: |
| 97 | + - 10.0.1.0/16 |
| 98 | + le: 24 |
| 99 | + ge:24 |
| 100 | + toAdvertise: |
| 101 | + allowed: |
| 102 | + prefixes: |
| 103 | + - 10.0.1.0/24 |
| 104 | + prefixes: |
| 105 | + - 10.0.1.0/24 |
| 106 | + imports: |
| 107 | + - vrf: blue |
| 108 | + nodeSelector: |
| 109 | + matchLabels: |
| 110 | + kubernetes.io/hostname: ovn-worker |
| 111 | +---- |
| 112 | + |
| 113 | +The generated `FRRConfiguration` object configures the subnet `10.0.1.0/24`, which belongs to VRF blue, is imported into the default VRF and advertised to the `172.18.0.5` neighbor. An `FRRConfiguration` object is generated for each node selected by a `RouteAdvertisements` CR with the appropriate prefixes that apply to each node. |
| 114 | + |
| 115 | +Because the `targetVRF` uses the default value, the routes are leaked and advertised in the default VRF. Additionally, routes are imported from the default VRF into the blue VRF. |
| 116 | + |
| 117 | +[id="advertising-pod-ips-from-a-user-defined-network-over-bgp-with-vpn_{context}"] |
| 118 | +== Advertising pod IPs from a user-defined network over BGP with VPN |
| 119 | + |
| 120 | +In this scenario, a VLAN interface is attached to the VRF device associated with the blue network. This setup provides a _VRF lite_ design where FRR-K8S is leveraged to advertise the blue network over only the corresponding VRF/VLAN link to the next hop PE router. The red tenant uses the same configuration. |
| 121 | + |
| 122 | +Red user-defined network:: |
| 123 | +- A VRF named `mp0-red` |
| 124 | +- A VLAN interface attached to the VRF device and connected to the external PE router |
| 125 | +- An assigned subnet of `10.0.2.0/24` |
| 126 | + |
| 127 | +Blue user-defined network:: |
| 128 | +- A VRF named `mp0-blue` |
| 129 | +- A VLAN interface attached to the VRF device and connected to the external PE router |
| 130 | +- An assigned subnet of `10.0.1.0/24` |
| 131 | + |
| 132 | +[NOTE] |
| 133 | +==== |
| 134 | +This approach is available only when using OVN-Kubernetes local gateway mode by setting `routingViaHost=true`. |
| 135 | +==== |
| 136 | + |
| 137 | +In the following configuration, an additional `FRRConfiguration` CR configures peering with the PE router on the blue and red VLANs: |
| 138 | + |
| 139 | +.`FRRConfiguration` CR manually configured for BGP VPN setup |
| 140 | +[source,yaml] |
| 141 | +---- |
| 142 | +apiVersion: frrk8s.metallb.io/v1beta1 |
| 143 | +kind: FRRConfiguration |
| 144 | +metadata: |
| 145 | + name: vpn-blue-red |
| 146 | + namespace: openshift-frr-k8s |
| 147 | + labels: |
| 148 | + routeAdvertisements: vpn-blue-red |
| 149 | +spec: |
| 150 | + bgp: |
| 151 | + routers: |
| 152 | + - asn: 64512 |
| 153 | + vrf: blue |
| 154 | + neighbors: |
| 155 | + - address: 182.18.0.5 |
| 156 | + asn: 64512 |
| 157 | + toReceive: |
| 158 | + allowed: |
| 159 | + mode: filtered |
| 160 | + - asn: 64512 |
| 161 | + vrf: red |
| 162 | + neighbors: |
| 163 | + - address: 192.18.0.5 |
| 164 | + asn: 64512 |
| 165 | + toReceive: |
| 166 | + allowed: |
| 167 | + mode: filtered |
| 168 | +---- |
| 169 | + |
| 170 | +The following `RouteAdvertisements` CR describes the configuration for the blue and red tenants: |
| 171 | + |
| 172 | +.`RouteAdvertisements` CR for the blue and red tenants |
| 173 | +[source,yaml] |
| 174 | +---- |
| 175 | +apiVersion: k8s.ovn.org/v1 |
| 176 | +kind: RouteAdvertisements |
| 177 | +metadata: |
| 178 | + name: default |
| 179 | +spec: |
| 180 | + targetVRF: auto |
| 181 | + advertisements: |
| 182 | + - PodNetwork |
| 183 | + networkSelector: |
| 184 | + matchExpressions: |
| 185 | + - { key: k8s.ovn.org/metadata.name, operator: In, values: [blue,red] } |
| 186 | + frrConfigurationSelector: |
| 187 | + matchLabels: |
| 188 | + routeAdvertisements: vpn-blue-red |
| 189 | +---- |
| 190 | + |
| 191 | +In the `RouteAdvertisements` CR the `targetVRF` is set to `auto` so that advertisements will occur within the VRF device corresponding to the individual networks selected. In this scenario, the pod subnet for blue is advertised over the blue VRF device and the pod subnet for red is advertised over the red VRF device. |
| 192 | + |
| 193 | +When the OVN-Kubernetes controller sees this `RouteAdvertisements` CR, it generates a `FRRConfiguration` object that configures the FRR daemon to advertise the routes for the blue and red tenants. |
| 194 | + |
| 195 | +.`FRRConfiguration` CR generated by OVN-Kubernetes for blue and red tenants |
| 196 | +[source,yaml] |
| 197 | +---- |
| 198 | +apiVersion: frrk8s.metallb.io/v1beta1 |
| 199 | +kind: FRRConfiguration |
| 200 | +metadata: |
| 201 | + name: ovnk-generated-abcde |
| 202 | + namespace: openshift-frr-k8s |
| 203 | +spec: |
| 204 | + bgp: |
| 205 | + routers: |
| 206 | + - asn: 64512 |
| 207 | + neighbors: |
| 208 | + - address: 182.18.0.5 |
| 209 | + asn: 64512 |
| 210 | + toReceive: |
| 211 | + allowed: |
| 212 | + prefixes: |
| 213 | + - 10.0.1.0/16 |
| 214 | + le: 24 |
| 215 | + ge:24 |
| 216 | + toAdvertise: |
| 217 | + allowed: |
| 218 | + prefixes: |
| 219 | + - 10.0.1.0/24 |
| 220 | + vrf: blue |
| 221 | + prefixes: |
| 222 | + - 10.0.1.0/24 |
| 223 | + - asn: 64512 |
| 224 | + neighbors: |
| 225 | + - address: 192.18.0.5 |
| 226 | + asn: 64512 |
| 227 | + toReceive: |
| 228 | + allowed: |
| 229 | + prefixes: |
| 230 | + - 10.0.2.0/16 |
| 231 | + le: 24 |
| 232 | + ge:24 |
| 233 | + toAdvertise: |
| 234 | + allowed: |
| 235 | + prefixes: |
| 236 | + - 10.0.2.0/24 |
| 237 | + vrf: red |
| 238 | + prefixes: |
| 239 | + - 10.0.2.0/24 |
| 240 | + nodeSelector: |
| 241 | + matchLabels: |
| 242 | + kubernetes.io/hostname: ovn-worker |
| 243 | +---- |
| 244 | + |
| 245 | +In this scenario, any filtering or selection of routes to receive must be done in the `FRRConfiguration` CR that defines peering relationships. An `FRRConfiguration` object is generated for each node selected by a `RouteAdvertisements` CR with the appropriate prefixes that apply to each node. |
0 commit comments