Updating Kubernetes Ingress from extensions/v1beta1 to networking.k8s.io/v1

kubernetes
2022-06-19 11:32 (3 years ago)
Updating Kubernetes Ingress from extensions/v1beta1 to networking.k8s.io/v1

In the latest version of Kubernetes (around 1.25?), apiVersion: extensions/v1beta1 is no longer usable.

If you have written Ingress using extensions/v1beta1, you will encounter the following error when applying with kubectl:

error: unable to recognize "ingress.yml": no matches for kind "Ingress" in version "extensions/v1beta1"

Therefore, you need to update it to apiVersion: networking.k8s.io/v1.

Although I have not confirmed whether apiVersion: networking.k8s.io/v1beta1 is also unusable, it would be wise to similarly update to apiVersion: networking.k8s.io/v1 to avoid future issues.

When doing so, note that the way to write backend.service has slightly changed.

Sample Manifest for apiVersion: networking.k8s.io/v1 with kind: Ingress

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: my-app-ingress
namespace: my-namespace
annotations:
ingress.kubernetes.io/ssl-redirect: "true"
spec:
tls:
- secretName: my-tls-cert-secrets
rules:
- host: my-app.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: my-app-service
port:
number: 80

In extensions/v1beta1, what was written as backend.serviceName and backend.servicePort has now been changed to backend.service.name and backend.service.port.number.
You also need to specify pathType. For the same behavior as before, use pathType: Prefix.

Please rate this article
Currently unrated
The author runs the application development company Cyberneura.
We look forward to discussing your development needs.

Categories

Archive