Migrate Service spec.loadBalancerIP to the MetalLB annotation
org.openrewrite.kubernetes.metallb.MigrateLoadBalancerIpToMetalLbAnnotationArtifactorg.openrewrite.recipe:rewrite-kubernetesMove 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.
Usage
This recipe has no required configuration options. You’ll need the Moderne CLI configured before running the command below.
mod run . --recipe org.openrewrite.kubernetes.metallb.MigrateLoadBalancerIpToMetalLbAnnotationIf the recipe isn’t available locally, install it with:
mod config recipes jar install org.openrewrite.recipe:rewrite-kubernetes:RELEASEOptions
| Name | Type | Description |
|---|---|---|
fileMatcher | String | Matching files will be modified. This is a glob expression. e.g. **/service-*.yml |
Data tables
Structured output this recipe can produce.
- Source files that had resultsSource files that were modified by the recipe run.
org.openrewrite.table.SourcesFileResults - Source files that had search resultsSearch results that were found during the recipe run.
org.openrewrite.table.SearchResults - Source files that errored on a recipeThe details of all errors produced by a recipe run.
org.openrewrite.table.SourcesFileErrors - Recipe performanceStatistics used in analyzing the performance of recipes.
org.openrewrite.table.RecipeRunStats