Migrate Service spec.loadBalancerIP to the MetalLB annotation

Proprietary

Move the address a type: LoadBalancer Service pins in spec.loadBalancerIP, deprecated in Kubernetes 1.24, into the metallb.io/loadBalancerIPs annotation MetalLB reads in its place. spec.loadBalancerIP holds a single address, so a dual stack service can name only one of its two families there and silently takes whatever MetalLB allocates for the other; the annotation takes a comma separated list and is the only way to pin both.

MetalLB refuses to allocate at all for a service that sets both the annotation and spec.loadBalancerIP. Where the annotation is already present this therefore drops spec.loadBalancerIP when the two agree, and reports it when they disagree rather than picking an address on the author's behalf.

This annotation means nothing to a cloud provider's load balancer controller, so run it only against manifests MetalLB serves.

org.openrewrite.kubernetes.metallb.MigrateLoadBalancerIpToMetalLbAnnotation

Optional

Matching files will be modified. This is a glob expression.

mod run . --recipe=org.openrewrite.kubernetes.metallb.MigrateLoadBalancerIpToMetalLbAnnotation

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.