Skip to main content

Removing Deprecated Ingress APIs for Cloud Platform - Kubernetes v1.22

All beta Ingress API versions such as extensions/v1beta1 and networking.k8s.io/v1beta1 have been deprecated and are not available in Kubernetes v1.22 or the new nginx-ingress-controller v1.2

This user guide describes how to use the following stable Ingress API which is required for all ingresses:

  • networking.k8s.io/v1

The replacement Ingress v1 API is available within the current Cloud Platform Kubernetes version 1.21 and nginx-ingress-controller v0.47.0

To view which apiVersion you are using, run the following kubectl command:

kubectl --namespace <namespace> get ingress <ingress-name> -o yaml

apiVersion: networking.k8s.io/v1
kind: Ingress

Resources deployed using kubectl

If your ingress is using a beta version of the ingress API, it should look similar to the following:

apiVersion: networking.k8s.io/v1beta1 OR extensions/v1beta1
kind: Ingress
metadata:
  name: helloworld
  annotations:
    kubernetes.io/ingress.class: nginx
    external-dns.alpha.kubernetes.io/set-identifier: helloworld-mynamespace-green
    external-dns.alpha.kubernetes.io/aws-weight: "100"
spec:
  tls:
  - hosts:
    - helloworld-app.apps.live.cloud-platform.service.justice.gov.uk
  rules:
  - host: helloworld-app.apps.live.cloud-platform.service.justice.gov.uk
    http:
      paths:
      - path: /
        backend:
          serviceName: helloworld
          servicePort: 4567

Convert the manifest to use the networking.k8s.io/v1 API version syntax:

  • Change the apiVersion to networking.k8s.io/v1
  • Add pathType: ImplementationSpecific after path: /
  • For serviceName, rename -backend.serviceName to -backend.service.name
  • For String servicePort, rename -backend.servicePort to -backend.service.port.name
  • For Numeric servicePort, rename -backend.servicePort to -backend.service.port.number

The manifest should look like the below after the changes:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: helloworld
  annotations:
    kubernetes.io/ingress.class: nginx
    external-dns.alpha.kubernetes.io/set-identifier: helloworld-mynamespace-green
    external-dns.alpha.kubernetes.io/aws-weight: "100"
spec:
  tls:
  - hosts:
    - helloworld-app.apps.live.cloud-platform.service.justice.gov.uk
  rules:
  - host: helloworld-app.apps.live.cloud-platform.service.justice.gov.uk
    http:
      paths:
      - path: /
        pathType: ImplementationSpecific
        backend:
          service:
            name: helloworld
            port:
              number: 4567

To apply your changes:

kubectl apply --filename ingress.yaml --namespace <namespace>

Resources deployed using a helm chart

NOTE - Check the helm version

The Cloud Platform runs on Kubernetes v1.21 and is compatible with helm version 3.5.x. Please make sure you have the correct version installed before updating the manifest. If you are on older helm versions, you might get an error below:

Error: UPGRADE FAILED: rendered manifests contain a new resource that already exists. 
Unable to continue with update: existing resource conflict: namespace: XXX, name: YYYY,
existing_kind: networking.k8s.io/v1, Kind=Ingress, new_kind: networking.k8s.io/v1, Kind=Ingress

If your ingress manifest looks similar to below:

{{- if .Values.ingress.enabled -}}
{{- $fullName := include "app.fullname" . -}}
{{- $ingressPath := .Values.ingress.path -}}
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: {{ $fullName }}
  labels:
    {{- include "app.labels" . | nindent 4 }}
  annotations:
  {{- with .Values.ingress.annotations }}
    {{- toYaml . | nindent 4 }}
  {{- end }}
spec:
  tls:
  {{- range .Values.ingress.hosts }}
  - hosts:
    - {{ .host }}
    {{ if .cert_secret }}secretName: {{ .cert_secret }}{{ end }}
  {{- end }}
  rules:
  {{- range .Values.ingress.hosts }}
    - host: {{ .host }}
      http:
        paths:
          - path: {{ $ingressPath }}
            backend:
              serviceName: {{ $fullName }}
              servicePort: http
  {{- end }}
{{- end }}

The manifest after changes will look like:

{{- if .Values.ingress.enabled -}}
{{- $fullName := include "app.fullname" . -}}
{{- $ingressPath := .Values.ingress.path -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: {{ $fullName }}
  labels:
    {{- include "app.labels" . | nindent 4 }}
  annotations:
  {{- with .Values.ingress.annotations }}
    {{- toYaml . | nindent 4 }}
  {{- end }}
spec:
  tls:
  {{- range .Values.ingress.hosts }}
  - hosts:
    - {{ .host }}
    {{ if .cert_secret }}secretName: {{ .cert_secret }}{{ end }}
  {{- end }}
  rules:
  {{- range .Values.ingress.hosts }}
    - host: {{ .host }}
      http:
        paths:
          - path: {{ $ingressPath }}
            pathType: ImplementationSpecific
            backend:
              service:
                name: {{ $fullName }}
                port: 
                  name: http
  {{- end }}
{{- end }}

To apply your changes:

helm upgrade -f <values-file.yaml> <your-release> <your-chart> --namespace <your-namespace>

Getting help

If you have any questions, please contact us on #ask-cloud-platform Slack channel.

This page was last reviewed on 29 July 2022. It needs to be reviewed again on 29 October 2022 .
This page was set to be reviewed before 29 October 2022. This might mean the content is out of date.