Configuring community alias
As a cluster administrator, you can configure a community alias and use it across different advertisements.
About the community custom resource
To simplify BGP configuration, define named aliases for community values by using the community custom resource. You can reference these aliases when advertising ipAddressPools with the BGPAdvertisement resource.
The fields for the community custom resource are described in the following table.
The community CRD applies only to BGPAdvertisement.
MetalLB community custom resource
| Field | Type | Description |
|---|---|---|
metadata.name |
string |
Specifies the name for the community. |
metadata.namespace |
string |
Specifies the namespace for the community. Specify the same namespace that the MetalLB Operator uses. |
spec.communities |
string |
Specifies a list of BGP community aliases that can be used in BGPAdvertisements. A community alias consists of a pair of name (alias) and value (number:number). Link the BGPAdvertisement to a community alias by referring to the alias name in its spec.communities field. |
CommunityAlias
| Field | Type | Description |
|---|---|---|
name |
string |
The name of the alias for the community. |
value |
string |
The BGP community value corresponding to the given name. |
Configure MetalLB with a BGP advertisement and community alias
To advertise an IPAddressPool by using the BGP protocol, configure MetalLB with a community alias. This configuration sets the alias to the numeric value of the NO_ADVERTISE community.
In the following example, the peer BGP router doc-example-peer-community receives one 203.0.113.200/32 route and one fc00:f853:ccd:e799::1/128 route for each load-balancer IP address that MetalLB assigns to a service. A community alias is configured with the NO_ADVERTISE community.
Prerequisites
- Install the OpenShift CLI (
oc) - Log in as a user with
cluster-adminprivileges.
Procedure
- Create an IP address pool.
- Create a file, such as
ipaddresspool.yaml, with content like the following example:apiVersion: metallb.io/v1beta1kind: IPAddressPoolmetadata:namespace: metallb-systemname: doc-example-bgp-communityspec:addresses:- 203.0.113.200/30- fc00:f853:ccd:e799::/124 - Apply the configuration for the IP address pool:
$ oc apply -f ipaddresspool.yaml
- Create a file, such as
- Create a community alias named
community1.apiVersion: metallb.io/v1beta1kind: Communitymetadata:name: community1namespace: metallb-systemspec:communities:- name: NO_ADVERTISEvalue: '65535:65282' - Create a BGP peer named
doc-example-bgp-peer.- Create a file, such as
bgppeer.yaml, with content like the following example:apiVersion: metallb.io/v1beta2kind: BGPPeermetadata:namespace: metallb-systemname: doc-example-bgp-peerspec:peerAddress: 10.0.0.1peerASN: 64501myASN: 64500routerID: 10.10.10.10 - Apply the configuration for the BGP peer:
$ oc apply -f bgppeer.yaml
- Create a file, such as
- Create a BGP advertisement with the community alias.
-
Create a file, such as
bgpadvertisement.yaml, with content like the following example:apiVersion: metallb.io/v1beta1kind: BGPAdvertisementmetadata:name: bgp-community-samplenamespace: metallb-systemspec:aggregationLength: 32aggregationLengthV6: 128communities:- NO_ADVERTISEipAddressPools:- doc-example-bgp-communitypeers:- doc-example-peerwhere:
NO_ADVERTISE: Specifies theCommunityAlias.namehere and not the community custom resource (CR) name. -
Apply the configuration:
$ oc apply -f bgpadvertisement.yaml
-