Updating Ingresses to networking.k8s.io/v1

Updating Ingresses to networking.k8s.io/v1

Using Ingress with the extensions/v1beta1 API has been deprecated in Kubernetes 1.14 and will be removed in 1.22. This article presents how to update an existing manifest to the new API, networking.k8s.io/v1.

Let's start with an example manifest using the extensions/v1beta api:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: example-ingress
  namespace: example-namespace
  annotations:
    kubernetes.io/ingress.class: nginx
    cert-manager.io/cluster-issuer: letsencrypt-prod
spec:
  tls:
    - hosts:
        - example.com
      secretName: example-secret
  rules:
    - host: example.com
      http:
        paths:
          - path: /
            backend:
              serviceName: example-service
              servicePort: 80

When using the new networking.k8s.io/v1 API, the ingress manifest becomes:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: example-ingress
  namespace: example-namespace
  annotations:
    kubernetes.io/ingress.class: nginx
    cert-manager.io/cluster-issuer: letsencrypt-prod
spec:
  tls:
    - hosts:
        - example.com
      secretName: example-secret
  rules:
    - host: example.com
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service: 
                name: example
                port:
                  number: 80

It can be seen that changes involve adding a pathType property to each of the paths and rewriting the service section after it.