← All recipes
Moderne licensed

Migrate Ingress to networking.k8s.io/v1

Recipe IDorg.openrewrite.kubernetes.migrate.MigrateIngressToNetworkingV1Artifactorg.openrewrite.recipe:rewrite-kubernetes

Move Ingress from extensions/v1beta1 and networking.k8s.io/v1beta1, both removed in Kubernetes v1.22, to networking.k8s.io/v1, restructuring the body the new version requires. spec.backend becomes spec.defaultBackend, every backend.serviceName and backend.servicePort pair becomes backend.service.name and backend.service.port, and every path gains the explicit pathType: ImplementationSpecific that v1beta1 used to default to. servicePort is an int-or-string, so how it is written decides where it lands: an unquoted 8080 is the port number and becomes port.number, while a quoted "8080" or a bare http is the port's name and becomes port.name. An Ingress the restructuring cannot carry over in full is left on its old API version and marked with the reason, rather than being handed to the apiserver in a shape it rejects.

Single recipeProprietary

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.migrate.MigrateIngressToNetworkingV1

If the recipe isn’t available locally, install it with:

mod config recipes jar install org.openrewrite.recipe:rewrite-kubernetes:RELEASE

Options

NameTypeDescription
migrateIngressClassAnnotationBooleanAlso move the deprecated kubernetes.io/ingress.class annotation to spec.ingressClassName. Off by default, and off in kubectl convert, because the two are not the same thing: the annotation is a free-form string each controller interprets for itself, while ingressClassName names an IngressClass resource that has to exist in the cluster. Turning this on for a cluster whose controller reads only the annotation, or that has no matching IngressClass, leaves the Ingress unclaimed.
fileMatcherStringMatching files will be modified. This is a glob expression.
e.g. **/ingress-*.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