I had the below YAML for my Ingress and it worked (and continues to work):
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: test-ingress
namespace: test-layer
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
rules:
- host: mylocalhost.com
http:
paths:
- path: /
backend:
serviceName: test-app
servicePort: 5000
However, it tells me that it's deprecated and I should change to using networking.k8s.io/v1
. When I do that (see below) it throws an error.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: test-ingress
namespace: test-layer
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
rules:
- host: mylocalhost.com
http:
paths:
- path: /
backend:
serviceName: test-app
servicePort: 5000
ERROR
error: error validating "test-ingress.yaml":
error validating data: [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];
if you choose to ignore these errors, turn validation off with --validate=false
Other than changing the API version, I made no other changes.
kubectl version
returns:
Client Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.0", GitCommit:"e19964183377d0ec2052d1f1fa930c4d7575bd50", GitTreeState:"clean", BuildDate:"2020-08-26T14:30:33Z", GoVersion:"go1.15", Compiler:"gc", Platform:"windows/amd64"}
Server Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.0", GitCommit:"e19964183377d0ec2052d1f1fa930c4d7575bd50", GitTreeState:"clean", BuildDate:"2020-08-26T14:23:04Z", GoVersion:"go1.15", Compiler:"gc", Platform:"linux/amd64"}
I think that this PR contains the change you're asking about.
If you look in the 1.19 Ingress doc, it looks like the new syntax would be:
I unfortunately don't have a 1.19 cluster to test myself, but I think this is what you're running into.