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 community CRD applies only to BGPAdvertisement.

Table 1. MetalLB community custom resource
FieldTypeDescription

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 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.

Table 2. CommunityAlias
FieldTypeDescription

name

string

The name of the alias for the community.

value

string

The BGP community value corresponding to the given name.

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

  1. Create an IP address pool.

    1. Create a file, such as ipaddresspool.yaml, with content like the following example:

      1. apiVersion: metallb.io/v1beta1
      2. kind: IPAddressPool
      3. metadata:
      4. namespace: metallb-system
      5. name: doc-example-bgp-community
      6. spec:
      7. addresses:
      8. - 203.0.113.200/30
      9. - fc00:f853:ccd:e799::/124
    2. Apply the configuration for the IP address pool:

      1. $ oc apply -f ipaddresspool.yaml
  2. Create a community alias named community1.

    1. apiVersion: metallb.io/v1beta1
    2. kind: Community
    3. metadata:
    4. name: community1
    5. namespace: metallb-system
    6. spec:
    7. communities:
    8. - name: NO_ADVERTISE
    9. - value: '65535:65282'
  3. Create a BGP peer named doc-example-bgp-peer.

    1. Create a file, such as bgppeer.yaml, with content like the following example:

      1. apiVersion: metallb.io/v1beta1
      2. kind: BGPPeer
      3. metadata:
      4. namespace: metallb-system
      5. name: doc-example-bgp-peer
      6. spec:
      7. peerAddress: 10.0.0.1
      8. peerASN: 64501
      9. myASN: 64500
      10. routerID: 10.10.10.10
    2. Apply the configuration for the BGP peer:

      1. $ oc apply -f bgppeer.yaml
  4. Create a BGP advertisement with the community alias.

    1. Create a file, such as bgpadvertisement.yaml, with content like the following example:

      1. apiVersion: metallb.io/v1beta1
      2. kind: BGPAdvertisement
      3. metadata:
      4. name: bgp-community-sample
      5. namespace: metallb-system
      6. spec:
      7. aggregationLength: 32
      8. aggregationLengthV6: 128
      9. communities:
      10. - community1
      11. ipAddressPools:
      12. - doc-example-bgp-community
      13. peers:
      14. - doc-example-peer
    2. Apply the configuration:

      1. $ oc apply -f bgpadvertisement.yaml