To define the IP address ranges available for load balancer services, configure the properties of the MetalLB IPAddressPool custom resource (CR).
The following table details the parameters for the IPAddressPool CR:
Table 1. MetalLB IPAddressPool pool custom resource
| Parameter |
Type |
Description |
metadata.name
|
string
|
Specifies the name for the address pool. When you add a service, you can specify this pool name in the metallb.io/address-pool annotation to select an IP address from a specific pool. The names doc-example, silver, and gold are used throughout the documentation.
|
metadata.namespace
|
string
|
Specifies the namespace for the address pool. Specify the same namespace that the MetalLB Operator uses.
|
metadata.label
|
string
|
Optional: Specifies the key-value pair assigned to the IPAddressPool. This can be referenced by the ipAddressPoolSelectors in the BGPAdvertisement and L2Advertisement CRD to associate the IPAddressPool with the advertisement
|
spec.addresses
|
string
|
Specifies a list of IP addresses for the MetalLB Operator to assign to services. You can specify multiple ranges in a single pool, where these ranges all share the same settings. Specify each range in Classless Inter-Domain Routing (CIDR) notation or as starting and ending IP addresses separated with a hyphen.
|
spec.autoAssign
|
boolean
|
Optional: Specifies whether the MetalLB Operator automatically assigns IP addresses from this pool.
Specify false if you want to explicitly request an IP address from this pool with the metallb.io/address-pool annotation. The default value is true.
|
|
For IP address pool configurations, ensure the addresses parameter specifies only IP addresses that are available and not in use by other network devices, especially gateway addresses, to prevent conflicts when autoAssign is enabled.
|
|
spec.avoidBuggyIPs
|
boolean
|
Optional: When you set the parameter to enabled, the IP addresses ending .0 and .255 are not allocated from the pool. The default value is false. Some older consumer network equipment mistakenly block IP addresses ending in .0 and .255.
|
You can assign IP addresses from an IPAddressPool to services and namespaces by configuring the spec.serviceAllocation specification.
Table 2. MetalLB IPAddressPool custom resource spec.serviceAllocation subfields
| Parameter |
Type |
Description |
priority
|
int
|
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.
|
namespaces
|
array (string)
|
Optional: Specifies a list of namespaces that you can assign to IP addresses in an IP address pool.
|
namespaceSelectors
|
array (LabelSelector)
|
Optional: Specifies namespace labels that you can assign to IP addresses from an IP address pool by using label selectors in a list format.
|
serviceSelectors
|
array (LabelSelector)
|
Optional: Specifies service labels that you can assign to IP addresses from an address pool by using label selectors in a list format.
|