Can't change apiVersion of an deployed Ingress from extensions/v1beta1 to networking.k8s.io/v1

6/19/2021
Current version: 
Client Version: version.Info{Major:"1", Minor:"20", GitVersion:"v1.20.0", GitCommit:"af46c47ce925f4c4ad5cc8d1fca46c7b77d13b38", GitTreeState:"clean", BuildDate:"2020-12-08T17:59:43Z", GoVersion:"go1.15.5", Compiler:"gc", Platform:"windows/amd64"}
Server Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.9", GitCommit:"9dd794e454ac32d97cde41ae10be801ae98f75df", GitTreeState:"clean", BuildDate:"2021-03-18T01:00:06Z", GoVersion:"go1.15.8", Compiler:"gc", Platform:"linux/amd64"}

kubectl version --short:
Client Version: v1.20.0
Server Version: v1.19.9

I have tried to change the apiVersion through kubectl edit command and save it and was getting below error message added up in the YAML file after saving the file:

Warning: extensions/v1beta1 Ingress is deprecated in v1.14+, unavailable in v1.22+; use networking.k8s.io/v1 Ingress

Error Message:

ingresses.extensions "current-ingress" was not valid: <nil>: Invalid value: "The edited file failed validation":  [ValidationError(Ingress.spec.rules[0].http.paths[0].backend): unknown >field "serviceName" in io.k8s.api.networking.v1.IngressBackend, >ValidationError(Ingress.spec.rules[0].http.paths[0].backend): unknown >field "servicePort" in io.k8s.api.networking.v1.IngressBackend]

spec:
  rules:
  - host: // hostname
    http:
      paths:
      - backend:
          serviceName: location
          servicePort: 80
        path: /
        pathType: ImplementationSpecific

snippet here

Above is the format it has for serviceName and servicePort in the YAML file, I think that's the right way to write serviceName and servicePort declaration. If not, guide me here.

Could anyone help me how we can change the apiVersion of an deployed Ingress.

Thanks in Advance!

-- Sandeep Reddy
kubernetes
kubernetes-ingress

1 Answer

6/22/2021

Don't worry about the warning, it's just to inform you about the available API versioning as per this issue.

For the error it seems like you're using an outdated format, which has changed with networking.k8s.io/v1 as per this PR, so it should be service.name and servic.port.number.

Please refer to the official Kubernetes documentation for more information.

-- Jakub Siemaszko
Source: StackOverflow