Skip to content

Commit 6545c58

Browse files
authored
Merge pull request #55756 from rohennes/TELCODOCS-423-metallb-service-allocation
Adding an example for TELCODOCS-423
2 parents c0ed381 + d0e000b commit 6545c58

File tree

3 files changed

+73
-4
lines changed

3 files changed

+73
-4
lines changed

modules/nw-metallb-addresspool-cr.adoc

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88

99
[NOTE]
1010
====
11-
The address pool custom resource definition (CRD) and API documented in "Load balancing with MetalLB" in {product-title} 4.10 can still be used in {product-version}. However, the enhanced functionality associated with advertising the `IPAddressPools` with layer 2 or the BGP protocol is not supported when using the address pool CRD.
11+
The address pool custom resource definition (CRD) and API documented in "Load balancing with MetalLB" in {product-title} 4.10 can still be used in {product-version}. However, the enhanced functionality associated with advertising an IP address from an `IPAddressPool` with layer 2 protocols, or the BGP protocol, is not supported when using the `AddressPool` CRD.
1212
====
1313

14-
The fields for the `IPAddressPool` custom resource are described in the following table.
14+
The fields for the `IPAddressPool` custom resource are described in the following tables.
1515

1616
.MetalLB IPAddressPool pool custom resource
1717
[cols="1,1,3a", options="header"]
@@ -49,3 +49,31 @@ Specify `false` if you want explicitly request an IP address from this pool with
4949
The default value is `true`.
5050

5151
|===
52+
53+
You can assign IP addresses from an `IPAddressPool` to services and namespaces by configuring the `spec.serviceAllocation` specification.
54+
55+
.MetalLB IPAddressPool custom resource spec.serviceAllocation subfields
56+
[cols="1,1,3a", options="header"]
57+
|===
58+
59+
|Field
60+
|Type
61+
|Description
62+
63+
|`priority`
64+
|`int`
65+
|Optional: Defines the priority between IP address pools when more than one IP address pool matches a service or namespace. A lower number indicates a higher priority.
66+
67+
|`namespaces`
68+
|`array (string)`
69+
|Optional: Specifies a list of namespaces that you can assign to IP addresses in an IP address pool.
70+
71+
|`namespaceSelectors`
72+
|`array (LabelSelector)`
73+
|Optional: Specifies namespace labels that you can assign to IP addresses from an IP address pool by using label selectors in a list format.
74+
75+
|`serviceSelectors`
76+
|`array (LabelSelector)`
77+
|Optional: Specifies service labels that you can assign to IP addresses from an address pool by using label selectors in a list format.
78+
79+
|===

modules/nw-metallb-example-addresspool.adoc

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,44 @@ spec:
6262
- 10.0.100.0/28
6363
- 2002:2:2::1-2002:2:2::100
6464
----
65+
66+
== Example: Assign IP address pools to services or namespaces
67+
You can assign IP addresses from an `IPAddressPool` to services and namespaces that you specify.
68+
69+
If you assign a service or namespace to more than one IP address pool, MetalLB uses an available IP address from the higher-priority IP address pool. If no IP addresses are available from the assigned IP address pools with a high priority, MetalLB uses available IP addresses from an IP address pool with lower priority or no priority.
70+
71+
[NOTE]
72+
====
73+
You can use the `matchLabels` label selector, the `matchExpressions` label selector, or both, for the `namespaceSelectors` and `serviceSelectors` specifications. This example demonstrates one label selector for each specification.
74+
====
75+
76+
[source,yaml]
77+
----
78+
apiVersion: metallb.io/v1beta1
79+
kind: IPAddressPool
80+
metadata:
81+
name: doc-example-service-allocation
82+
namespace: metallb-system
83+
spec:
84+
addresses:
85+
- 192.168.20.0/24
86+
serviceAllocation:
87+
priority: 50 <1>
88+
namespaces: <2>
89+
- namespace-a
90+
- namespace-b
91+
namespaceSelectors: <3>
92+
- matchLabels:
93+
zone: east
94+
serviceSelectors: <4>
95+
- matchExpressions:
96+
- key: security
97+
operator: In
98+
values:
99+
- S1
100+
----
101+
<1> Assign a priority to the address pool. A lower number indicates a higher priority.
102+
<2> Assign one or more namespaces to the IP address pool in a list format.
103+
<3> Assign one or more namespace labels to the IP address pool by using label selectors in a list format.
104+
<4> Assign one or more service labels to the IP address pool by using label selectors in a list format.
105+

modules/nw-metallb-operator-custom-resources.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ An `IPAddressPool` includes a list of IP addresses.
1818
The list can be a single IP address that is set using a range, such as 1.1.1.1-1.1.1.1, a range specified in CIDR notation, a range specified as a starting and ending address separated by a hyphen, or a combination of the three.
1919
An `IPAddressPool` requires a name.
2020
The documentation uses names like `doc-example`, `doc-example-reserved`, and `doc-example-ipv6`.
21-
An `IPAddressPool` assigns IP addresses from the pool.
21+
The MetalLB `controller` assigns IP addresses from a pool of addresses in an `IPAddressPool`.
2222
`L2Advertisement` and `BGPAdvertisement` custom resources enable the advertisement of a given IP from a given pool.
23+
You can assign IP addresses from an `IPAddressPool` to services and namespaces by using the `spec.serviceAllocation` specification in the `IPAddressPool` custom resource.
2324
+
2425
[NOTE]
2526
====
2627
A single `IPAddressPool` can be referenced by a L2 advertisement and a BGP advertisement.
2728
====
2829

29-
3030
`BGPPeer`::
3131
The BGP peer custom resource identifies the BGP router for MetalLB to communicate with, the AS number of the router, the AS number for MetalLB, and customizations for route advertisement.
3232
MetalLB advertises the routes for service load-balancer IP addresses to one or more BGP peers.

0 commit comments

Comments
 (0)