|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * networking/metallb/about-advertising-ipaddresspool.adoc |
| 4 | + |
| 5 | +:_content-type: PROCEDURE |
| 6 | +[id="nw-metallb-configure-with-L2-advertisement-interface_{context}"] |
| 7 | += Configuring MetalLB with an L2 advertisement for selected interfaces |
| 8 | + |
| 9 | +By default, the IP addresses from IP address pool that has been assigned to the service, is advertised from all the network interfaces. The `interfaces` field in the `L2Advertisement` custom resource definition is used to restrict those network interfaces that advertise the IP address pool. |
| 10 | + |
| 11 | +This example shows how to configure MetalLB so that the IP address pool is advertised only from the network interfaces listed in the `interfaces` field of all nodes. |
| 12 | + |
| 13 | +.Prerequisites |
| 14 | + |
| 15 | +* You have installed the OpenShift CLI (`oc`). |
| 16 | +
|
| 17 | +* You are logged in as a user with `cluster-admin` privileges. |
| 18 | +
|
| 19 | +.Procedure |
| 20 | + |
| 21 | +. Create an IP address pool. |
| 22 | + |
| 23 | +.. Create a file, such as `ipaddresspool.yaml`, and enter the configuration details like the following example: |
| 24 | ++ |
| 25 | +[source,yaml] |
| 26 | +---- |
| 27 | +apiVersion: metallb.io/v1beta1 |
| 28 | +kind: IPAddressPool |
| 29 | +metadata: |
| 30 | + namespace: metallb-system |
| 31 | + name: doc-example-l2 |
| 32 | +spec: |
| 33 | + addresses: |
| 34 | + - 4.4.4.0/24 |
| 35 | + autoAssign: false |
| 36 | +---- |
| 37 | + |
| 38 | +.. Apply the configuration for the IP address pool like the following example: |
| 39 | ++ |
| 40 | +[source,terminal] |
| 41 | +---- |
| 42 | +$ oc apply -f ipaddresspool.yaml |
| 43 | +---- |
| 44 | + |
| 45 | +. Create a L2 advertisement advertising the IP with `interfaces` selector. |
| 46 | + |
| 47 | +.. Create a YAML file, such as `l2advertisement.yaml`, and enter the configuration details like the following example: |
| 48 | ++ |
| 49 | +[source,yaml] |
| 50 | +---- |
| 51 | +apiVersion: metallb.io/v1beta1 |
| 52 | +kind: L2Advertisement |
| 53 | +metadata: |
| 54 | + name: l2advertisement |
| 55 | + namespace: metallb-system |
| 56 | +spec: |
| 57 | + ipAddressPools: |
| 58 | + - doc-example-l2 |
| 59 | + interfaces: |
| 60 | + - interfaceA |
| 61 | + - interfaceB |
| 62 | +---- |
| 63 | + |
| 64 | +.. Apply the configuration for the advertisement like the following example: |
| 65 | ++ |
| 66 | +[source,terminal] |
| 67 | +---- |
| 68 | +$ oc apply -f l2advertisement.yaml |
| 69 | +---- |
| 70 | + |
| 71 | +[IMPORTANT] |
| 72 | +==== |
| 73 | +The interface selector does not affect how MetalLB chooses the node to announce a given IP by using L2. The chosen node does not announce the service if the node does not have the selected interface. |
| 74 | +==== |
0 commit comments