140

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"}
Don Rhummy
  • 24,730
  • 42
  • 175
  • 330

2 Answers2

293

I think that this PR contains the change you're asking about.

`Ingress` and `IngressClass` resources have graduated to `networking.k8s.io/v1`. Ingress and IngressClass types in the `extensions/v1beta1` and `networking.k8s.io/v1beta1` API versions are deprecated and will no longer be served in 1.22+. Persisted objects can be accessed via the `networking.k8s.io/v1` API. Notable changes in v1 Ingress objects (v1beta1 field names are unchanged):
* `spec.backend` -> `spec.defaultBackend`
* `serviceName` -> `service.name`
* `servicePort` -> `service.port.name` (for string values)
* `servicePort` -> `service.port.number` (for numeric values)
* `pathType` no longer has a default value in v1; "Exact", "Prefix", or "ImplementationSpecific" must be specified
Other Ingress API updates:
* backends can now be resource or service backends
* `path` is no longer required to be a valid regular expression

If you look in the 1.19 Ingress doc, it looks like the new syntax would be:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: minimal-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
  - http:
      paths:
      - path: /testpath
        pathType: Prefix
        backend:
          service:
            name: test
            port:
              number: 80

I unfortunately don't have a 1.19 cluster to test myself, but I think this is what you're running into.

Howard_Roark
  • 4,088
  • 1
  • 14
  • 24
  • 6
    Thank you, that looks like it's right. Wish they'd update the high level documentation to match – Don Rhummy Sep 29 '20 at 22:28
  • 43
    How can they put such a breaking change in these config files! Cannot imagine the nightmaare for those in charge to maintain many complex deployment structures on kubernetes! – lyrio Jan 20 '21 at 02:50
  • 15
    @lyrio Because it was only in beta before and now it's a full version. Notice before it was `networking.k8s.io/v1beta1` and now it's the released version `networking.k8s.io/v1` – Don Rhummy Feb 12 '21 at 01:14
  • 1
    It works well - note for GKE users - the ingress update takes about 5 - 10 minutes WITH DOWNTIME on static ip – Mitzi Oct 04 '21 at 15:10
  • I <3 U, this help me a lot – Juandres Yepes Narvaez Jul 19 '22 at 21:34
-11

Please try the following:

% minikube addons enable dashboard
% minikube addons enable metrics-server

Then, change the apiVersion in dashboard-ingress.yaml to:

apiVersion: networking.k8s.io/v1beta1
Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77
  • 25
    Hi Abdul. Welcome to Stack Overflow and thank you for contributing. When your answer is downvoted, this can be discouraging. Don't let it be. It simply means that others did not find that this answer was a good match for the question being asked. You can (if you want) delete your answer (if you also agree it is off base and not going to help others), or leave it go. There's no harm either way. Contrats on taking the first step, and I look forward to you contributing to answer other questions. – PatS Mar 30 '21 at 01:21