// Module included in the following assemblies:
//
// * networking/ovn_kubernetes_network_provider/configuring-secondary-external-gateway.adoc

:_mod-docs-content-type: REFERENCE
[id="nw-secondary-ext-gw-object_{context}"]
= AdminPolicyBasedExternalRoute object configuration

[role="_abstract"]
You can define an `AdminPolicyBasedExternalRoute` object, which is cluster scoped, with specific properties.

A namespace can be selected by only one `AdminPolicyBasedExternalRoute` CR at a time.

The following tables detail supported fields for objects.

.`AdminPolicyBasedExternalRoute` object
[cols=".^3,.^2,.^5a",options="header"]

|====
|Field|Type|Description

|`metadata.name`
|`string`
|Specifies the name of the  `AdminPolicyBasedExternalRoute` object.

|`spec.from`
|`string`
|Specifies a namespace selector that the routing policies apply to. Only `namespaceSelector` is supported for external traffic. For example:

[source,yaml]
----
from:
  namespaceSelector:
    matchLabels:
      kubernetes.io/metadata.name: novxlan-externalgw-ecmp-4059
----

A namespace can only be targeted by 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 that target the same namespace. To apply updates, you must change the policy itself or related objects such as target namespaces, pod gateways, or namespaces hosting them from dynamic hops. The policy is then re-evaluated and your changes are applied.

|`spec.nextHops`
|`object`
| 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.

|====


.`nextHops` object
[cols=".^3,.^2,.^5a",options="header"]
|====
|Field|Type|Description

|`static`
|`array`
| Specifies an array of static IP addresses.

|`dynamic`
|`array`
| Specifies an array of pod selectors corresponding to pods configured with a network attachment definition to use as the external gateway target.

|====


.`nextHops.static` object
[cols=".^3,.^2,.^5a",options="header"]
|====
|Field|Type|Description

|`ip`
|`string`
| Specifies either an IPv4 or IPv6 address of the next destination hop.

|`bfdEnabled`
|`boolean`
|Optional field. Specifies whether Bi-Directional Forwarding Detection (BFD) is supported by the network. The default value is `false`.

|====

.`nextHops.dynamic` object
[cols=".^3,.^2,.^5a",options="header"]
|====
|Field|Type|Description

|`podSelector`
|`string`
|Specifies a set-based label selector to filter the pods in the namespace that match this network configuration. For more information, see "Set-based requirement" in the _Additional resources_ section.

|`namespaceSelector`
|`string`
|Specifies a `set-based` selector to filter the namespaces that the `podSelector` applies to. You must specify a value for this field.


|`bfdEnabled`
|`boolean`
|Optional field. Specifies whether Bi-Directional Forwarding Detection (BFD) is supported by the network. The default value is `false`.

|`networkAttachmentName`
|`string`
|Optional field. 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 configured as a host network pod to use the host network.

|====
