// Module included in the following assemblies:
//
// * networking/metallb/about-advertising-ipaddresspool.adoc

:_mod-docs-content-type: REFERENCE
[id="nw-metallb-bgpadvertisement-cr_{context}"]
= About the BGPAdvertisement custom resource

[role="_abstract"]
To configure how the cluster announces IP addresses to external peers, define the properties of the `BGPAdvertisement` custom resource (CR). Specifying these parameters ensures that MetalLB correctly manages routing advertisements for your application services within the network.

The following table describes the parameters for the `BGPAdvertisements` CR:

.BGPAdvertisements configuration
[cols="1,1,3a", options="header"]
|===

|Parameter
|Type
|Description

|`metadata.name`
|`string`
|Specifies the name for the BGP advertisement.

|`metadata.namespace`
|`string`
|Specifies the namespace for the BGP advertisement. Specify the same namespace that the MetalLB Operator uses.

|`spec.aggregationLength`
|`integer`
|Optional: Specifies the number of bits to include in a 32-bit CIDR mask. To aggregate the routes that the speaker advertises to BGP peers, the mask is applied to the routes for several service IP addresses and the speaker advertises the aggregated route. For example, with an aggregation length of `24`, the speaker can aggregate several `10.0.1.x/32` service IP addresses and advertise a single `10.0.1.0/24` route. If this `BGPAdvertisement` resource uses `spec.serviceSelectors` to limit the advertisement to labeled services, you must omit `aggregationLength` or set it to `32`; you cannot set another aggregation length on this same resource together with labeled service selection.

|`spec.aggregationLengthV6`
|`integer`
|Optional: Specifies the number of bits to include in a 128-bit CIDR mask. For example, with an aggregation length of `124`, the speaker can aggregate several `fc00:f853:0ccd:e799::x/128` service IP addresses and advertise a single `fc00:f853:0ccd:e799::0/124` route. If this `BGPAdvertisement` resource uses `spec.serviceSelectors` to limit the advertisement to labeled services, you must omit `aggregationLengthV6` or set it to `128`; you cannot set another aggregation length on this same resource together with labeled service selection.

|`spec.communities`
|`string`
|Optional: Specifies one or more BGP communities. Each community is specified as two 16-bit values separated by the colon character. Well-known communities must be specified as 16-bit values:

* `NO_EXPORT`: `65535:65281`
* `NO_ADVERTISE`: `65535:65282`
* `NO_EXPORT_SUBCONFED`: `65535:65283`

You can also use community objects that are created along with the strings.

|`spec.localPref`
|`integer`
|Optional: Specifies the local preference for this advertisement. This BGP attribute applies to BGP sessions within the Autonomous System.

|`spec.ipAddressPools`
|`string`
|Optional: The list of `IPAddressPools` to advertise with this advertisement, selected by name.

|`spec.ipAddressPoolSelectors`
|`string`
|Optional: A selector for the `IPAddressPools` that gets advertised with this advertisement. This is for associating the `IPAddressPool` to the advertisement based on the label assigned to the `IPAddressPool` instead of the name itself. If no `IPAddressPool` is selected by this or by the list, the advertisement is applied to all the `IPAddressPools`.

|`spec.serviceSelectors`
|`array (LabelSelector)`
|Optional: Kubernetes label selectors that determine which `LoadBalancer` services receive this advertisement's BGP policy for routes from the selected pools. If you omit `spec.serviceSelectors` or specify an empty list, MetalLB applies this advertisement to every `LoadBalancer` service that draws an IP address from the pools listed in `spec.ipAddressPools` or matched by `spec.ipAddressPoolSelectors`. You can use selectors to limit the advertisement to labeled services. On this `BGPAdvertisement` resource, if you use `spec.serviceSelectors` to limit the advertisement to labeled services, labeled service selection and custom BGP route aggregation are mutually exclusive: omit `spec.aggregationLength` and `spec.aggregationLengthV6` or set them to `32` (IPv4) and `128` (IPv6). You cannot set other aggregation lengths on this same resource together with labeled service selection.

|`spec.nodeSelectors`
|`string`
|Optional: By setting the `NodeSelectors` parameter, you can limit the nodes to announce as next hops for the load balancer IP. When empty, all the nodes are announced as next hops.

|`spec.peers`
|`string`
|Optional: Use a list to specify the `metadata.name` values for each `BGPPeer` resource that receives advertisements for the MetalLB service IP address. The MetalLB service IP address is assigned from the IP address pool. By default, the MetalLB service IP address is advertised to all configured `BGPPeer` resources. Set this parameter to limit the advertisement to specific `BGPpeer` resources.

|===
