Migrate Ingress to networking.k8s.io/v1
ProprietaryMove 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.
org. openrewrite. kubernetes. migrate. MigrateIngressToNetworkingV1Optional
Also 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.
Matching files will be modified. This is a glob expression.
mod run . --recipe= org. openrewrite. kubernetes. migrate. MigrateIngressToNetworkingV1Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.