Create an IPAddressPool in MetalLB in Kubernetes

Luca Berton
2 min readOct 30, 2024

To create an IPAddressPool in MetalLB with the metalb.io CRD (Custom Resource Definition), you can define it as a Kubernetes resource, specifying a range of IP addresses available to be assigned to LoadBalancer type services. Below is an example YAML manifest for the IPAddressPool CRD:

Example IPAddressPool CRD YAML

apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
name: my-ip-pool
namespace: metallb-system
spec:
addresses:
- 192.168.1.240-192.168.1.250
autoAssign: true # Optional, auto-assigns IPs from the pool

Breakdown:

  • apiVersion: metallb.io/v1beta1 specifies the version of the CRD.
  • kind: IPAddressPool defines the type of resource.
  • metadata: Contains the name and namespace of the resource. In most setups, MetalLB operates in the metallb-system namespace.
  • spec.addresses: Defines a list of IP ranges that MetalLB can assign to services of type LoadBalancer.
  • autoAssign: If set to true, MetalLB will automatically assign IP addresses from this pool to LoadBalancer services.

Once the IPAddressPool is created, MetalLB will use these IP addresses when Kubernetes LoadBalancer services request external IPs.

--

--

Luca Berton

I help creative Automation DevOps, Cloud Engineer, System Administrator, and IT Professional to succeed with Ansible Technology to automate more things everyday