Configuring community alias
As a cluster administrator, you can configure a community alias and use it across different advertisements.
About the community custom resource
The community
custom resource is a collection of aliases for communities. Users can define named aliases to be used when advertising ipAddressPools
using the BGPAdvertisement
. The fields for the community
custom resource are described in the following table.
The |
Field | Type | Description |
---|---|---|
|
| Specifies the name for the |
|
| Specifies the namespace for the |
|
| Specifies a list of IP addresses for MetalLB to assign to services. You can specify multiple ranges in a single pool, they will all share the same settings. Specify each range in CIDR notation or as starting and ending IP addresses separated with a hyphen. |
Field | Type | Description |
---|---|---|
|
| The name of the alias for the |
|
| The BGP |
Configuring MetalLB with a BGP advertisement and community alias
Configure MetalLB as follows so that the IPAddressPool
is advertised with the BGP protocol and the community alias set 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-admin
privileges.
Procedure
Create an IP address pool.
Create a file, such as
ipaddresspool.yaml
, with content like the following example:apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
namespace: metallb-system
name: doc-example-bgp-community
spec:
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 community alias named
community1
.apiVersion: metallb.io/v1beta1
kind: Community
metadata:
name: community1
namespace: metallb-system
spec:
communities:
- name: NO_ADVERTISE
- value: '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/v1beta1
kind: BGPPeer
metadata:
namespace: metallb-system
name: doc-example-bgp-peer
spec:
peerAddress: 10.0.0.1
peerASN: 64501
myASN: 64500
routerID: 10.10.10.10
Apply the configuration for the BGP peer:
$ oc apply -f bgppeer.yaml
Create a BGP advertisement with the community alias.
Create a file, such as
bgpadvertisement.yaml
, with content like the following example:apiVersion: metallb.io/v1beta1
kind: BGPAdvertisement
metadata:
name: bgp-community-sample
namespace: metallb-system
spec:
aggregationLength: 32
aggregationLengthV6: 128
communities:
- community1
ipAddressPools:
- doc-example-bgp-community
peers:
- doc-example-peer
Apply the configuration:
$ oc apply -f bgpadvertisement.yaml