kubernetes ingress, unknown field "serviceName" in io.k8s.api.networking.v1.IngressBackend,

4/20/2021

I am trying to add argocd ingress resource on my Azure Kubernetes Service (AKS)cluster. I follow this guide https://argoproj.github.io/argo-cd/operator-manual/ingress/#kubernetesingress-nginx

when I apply ingress resource on kubernete AKS cluster. it gave this following error message. it is working on AKS kubernete cluster v1.18.14

Anyone has met this same issue?

Cluster Environment:

Client Version: v1.20.0
Server Version: v1.19.6

Error message

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
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: argocd-server-http-ingress
  namespace: argocd
  annotations:
    kubernetes.io/ingress.class: "nginx-internal"
    nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
    nginx.ingress.kubernetes.io/backend-protocol: "HTTP"
spec:
  rules:
    - http:
        paths:
          - path: /argocd
            pathType: ImplementationSpecific
            backend:
              serviceName: argocd-server
              servicePort: http
      host: argocd.example.com
  tls:
    - hosts:
        - argocd.example.com
      secretName: argocd-secret # do not change, this is provided by Argo CD
-- Xin Cai
argocd
kubernetes
kubernetes-ingress

2 Answers

4/20/2021

Try: apiVersion: extensions/v1beta1 instead of networking.k8s.io/v1

-- Kiran Indukuri
Source: StackOverflow

4/20/2021

Please find below example ingress for 1.19 Kubernetes version

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

you can read more at : https://kubernetes.io/docs/concepts/services-networking/ingress/#the-ingress-resource

if you are running the Kubernetes version 1.18

example ingress will be something like

apiVersion: "networking.k8s.io/v1beta1"
kind: "Ingress"
metadata:
  name: "example-ingress"
spec:
  ingressClassName: "external-lb"
  rules:
  - host: "*.example.com"
    http:
      paths:
      - path: "/example"
        pathType: "Prefix"
        backend:
          serviceName: "example-service"
          servicePort: 80

you can read more about the improvement in Kubernetes official blog : https://kubernetes.io/blog/2020/04/02/improvements-to-the-ingress-api-in-kubernetes-1.18/

-- Harsh Manvar
Source: StackOverflow