|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * networking/ovn_kubernetes_network_provider/configuring-secondary-external-gateway.adoc |
| 4 | + |
| 5 | +:_content-type: CONCEPT |
| 6 | +[id="nw-secondary-ext-gw-object_{context}"] |
| 7 | += AdminPolicyBasedExternalRoute object configuration |
| 8 | + |
| 9 | +You can define an `AdminPolicyBasedExternalRoute` object, which is cluster scoped, with the following properties. A namespace can be selected by only one `AdminPolicyBasedExternalRoute` CR at a time. |
| 10 | + |
| 11 | +.`AdminPolicyBasedExternalRoute` object |
| 12 | +[cols=".^3,.^2,.^5a",options="header"] |
| 13 | + |
| 14 | +|==== |
| 15 | +|Field|Type|Description |
| 16 | + |
| 17 | +|`metadata.name` |
| 18 | +|`string` |
| 19 | +| |
| 20 | +Specifies the name of the `AdminPolicyBasedExternalRoute` object. |
| 21 | + |
| 22 | +|`spec.from` |
| 23 | +|`string` |
| 24 | +| |
| 25 | +Specifies a namespace selector that the routing polices apply to. Only `namespaceSelector` is supported for external traffic. For example: |
| 26 | + |
| 27 | +[source,yaml] |
| 28 | +---- |
| 29 | +from: |
| 30 | + namespaceSelector: |
| 31 | + matchLabels: |
| 32 | + kubernetes.io/metadata.name: novxlan-externalgw-ecmp-4059 |
| 33 | +---- |
| 34 | + |
| 35 | +A namespace can be targeted by only one `AdminPolicyBasedExternalRoute` CR. If a namespace is selected by more than one `AdminPolicyBasedExternalRoute` CR, a `failed` error status occurs on the second and subsequent CRs targeting the same namespace. |
| 36 | + |
| 37 | +|`spec.nextHops` |
| 38 | +|`object` |
| 39 | +| |
| 40 | +Specifies the destinations where the packets are forwarded to. Must be either or both of `static` and `dynamic`. You must have at least one next hop defined. |
| 41 | + |
| 42 | +|==== |
| 43 | + |
| 44 | + |
| 45 | +.`nextHops` object |
| 46 | +[cols=".^3,.^2,.^5a",options="header"] |
| 47 | +|==== |
| 48 | +|Field|Type|Description |
| 49 | + |
| 50 | +|`static` |
| 51 | +|`array` |
| 52 | +| Specifies an array of static IP addresses. |
| 53 | + |
| 54 | +|`dynamic` |
| 55 | +|`array` |
| 56 | +| Specifies an array of pod selectors corresponding to pods configured with a network attachment definition to use as the external gateway target. |
| 57 | + |
| 58 | +|==== |
| 59 | + |
| 60 | + |
| 61 | +.`nextHops.static` object |
| 62 | +[cols=".^3,.^2,.^5a",options="header"] |
| 63 | +|==== |
| 64 | +|Field|Type|Description |
| 65 | + |
| 66 | +|`ip` |
| 67 | +|`string` |
| 68 | +| Specifies either an IPv4 or IPv6 address of the next destination hop. |
| 69 | + |
| 70 | +|`bfdEnabled` |
| 71 | +|`boolean` |
| 72 | +|Optional: Specifies whether Bi-Directional Forwarding Detection (BFD) is supported by the network. The default value is `false`. |
| 73 | + |
| 74 | +|==== |
| 75 | + |
| 76 | +.`nextHops.dynamic` object |
| 77 | +[cols=".^3,.^2,.^5a",options="header"] |
| 78 | +|==== |
| 79 | +|Field|Type|Description |
| 80 | + |
| 81 | +|`podSelector` |
| 82 | +|`string` |
| 83 | +| |
| 84 | +Specifies a [set-based](https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#set-based-requirement) label selector to filter the pods in the namespace that match this network configuration. |
| 85 | + |
| 86 | +|`namespaceSelector` |
| 87 | +|`string` |
| 88 | +| Specifies a `set-based` selector to filter the namespaces that the `podSelector` applies to. You must specify a value for this field. |
| 89 | + |
| 90 | + |
| 91 | +|`bfdEnabled` |
| 92 | +|`boolean` |
| 93 | +|Optional: Specifies whether Bi-Directional Forwarding Detection (BFD) is supported by the network. The default value is `false`. |
| 94 | + |
| 95 | +|`networkAttachmentName` |
| 96 | +|`string` |
| 97 | +| |
| 98 | +Optional: Specifies the name of a network attachment definition. The name must match the list of logical networks associated with the pod. If this field is not specified, the host network of the pod is used. However, the pod must be configure as a host network pod to use the host network. |
| 99 | + |
| 100 | +|==== |
| 101 | + |
| 102 | +[id="example-secondary-external-gateway-configurations_{context}"] |
| 103 | +== Example secondary external gateway configurations |
| 104 | + |
| 105 | +In the following example, the `AdminPolicyBasedExternalRoute` object configures two static IP addresses as external gateways for pods in namespaces with the `kubernetes.io/metadata.name: novxlan-externalgw-ecmp-4059` label. |
| 106 | + |
| 107 | +[source,yaml] |
| 108 | +---- |
| 109 | +apiVersion: k8s.ovn.org/v1 |
| 110 | +kind: AdminPolicyBasedExternalRoute |
| 111 | +metadata: |
| 112 | + name: default-route-policy |
| 113 | +spec: |
| 114 | + from: |
| 115 | + namespaceSelector: |
| 116 | + matchLabels: |
| 117 | + kubernetes.io/metadata.name: novxlan-externalgw-ecmp-4059 |
| 118 | + nextHops: |
| 119 | + static: |
| 120 | + - ip: "172.18.0.8" |
| 121 | + - ip: "172.18.0.9" |
| 122 | +---- |
| 123 | + |
| 124 | +In the following example, the `AdminPolicyBasedExternalRoute` object configures a dynamic external gateway. The IP addresses used for the external gateway are derived from the additional network attachments associated with each of the selected pods. |
| 125 | + |
| 126 | +[source,yaml] |
| 127 | +---- |
| 128 | +apiVersion: k8s.ovn.org/v1 |
| 129 | +kind: AdminPolicyBasedExternalRoute |
| 130 | +metadata: |
| 131 | + name: shadow-traffic-policy |
| 132 | +spec: |
| 133 | + from: |
| 134 | + namespaceSelector: |
| 135 | + matchLabels: |
| 136 | + externalTraffic: "" |
| 137 | + nextHops: |
| 138 | + dynamic: |
| 139 | + - podSelector: |
| 140 | + matchLabels: |
| 141 | + gatewayPod: "" |
| 142 | + namespaceSelector: |
| 143 | + matchLabels: |
| 144 | + shadowTraffic: "" |
| 145 | + networkAttachmentName: shadow-gateway |
| 146 | + - podSelector: |
| 147 | + matchLabels: |
| 148 | + gigabyteGW: "" |
| 149 | + namespaceSelector: |
| 150 | + matchLabels: |
| 151 | + gatewayNamespace: "" |
| 152 | + networkAttachmentName: gateway |
| 153 | +---- |
| 154 | + |
| 155 | +In the following example, the `AdminPolicyBasedExternalRoute` object configures both static and dynamic external gateways. |
| 156 | + |
| 157 | +[source,yaml] |
| 158 | +---- |
| 159 | +apiVersion: k8s.ovn.org/v1 |
| 160 | +kind: AdminPolicyBasedExternalRoute |
| 161 | +metadata: |
| 162 | + name: multi-hop-policy |
| 163 | +spec: |
| 164 | + from: |
| 165 | + namespaceSelector: |
| 166 | + matchLabels: |
| 167 | + trafficType: "egress" |
| 168 | + nextHops: |
| 169 | + static: |
| 170 | + - ip: "172.18.0.8" |
| 171 | + - ip: "172.18.0.9" |
| 172 | + dynamic: |
| 173 | + - podSelector: |
| 174 | + matchLabels: |
| 175 | + gatewayPod: "" |
| 176 | + namespaceSelector: |
| 177 | + matchLabels: |
| 178 | + egressTraffic: "" |
| 179 | + networkAttachmentName: gigabyte |
| 180 | +---- |
0 commit comments