Hi, I have ingress resources yaml as like below: ``` cat ingress-resource/* -- . . .

ameya agashe:
Hi,
I have ingress resources yaml as like below:

cat ingress-resource/*
---
apiVersion: <http://networking.k8s.io/v1|networking.k8s.io/v1>
kind: Ingress
metadata:
  name: test-ingress
  annotations:
    <http://ingress.kubernetes.io/rewrite-target|ingress.kubernetes.io/rewrite-target>: /
spec:
  rules:
  - http:
      paths:
        - path: /cat
          backend:
            serviceName: cat-service
            servicePort: 5678
        - path: /dog
          backend:
            serviceName: dog-service
            servicePort: 5678
...
kind: Pod
apiVersion: v1
metadata:
  name: cat-app
  labels:
    app: cat
spec:
  containers:
    - name: cat-app
      image: hashicorp/http-echo
      args:
        - "-text=cat"

---

kind: Service
apiVersion: v1
metadata:
  name: cat-service
spec:
  selector:
    app: cat
  ports:
    - port: 5678  #Default port for image
kind: Pod
apiVersion: v1
metadata:
  name: dog-app
  labels:
    app: dog
spec:
  containers:
    - name: dog-app
      image: hashicorp/http-echo
      args:
        - "-text=dog"

---

kind: Service
apiVersion: v1
metadata:
  name: dog-service
spec:
  selector:
    app: dog
  ports:
    - port: 5678 # Default port for image

My error message is like below:

k apply -f ingress-resource/
pod/cat-app unchanged
service/cat-service unchanged
pod/dog-app unchanged
service/dog-service unchanged
error: error validating "ingress-resource/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, ValidationError(Ingress.spec.rules[0].http.paths[0]): missing required field "pathType" in io.k8s.api.networking.v1.HTTPIngressPath, ValidationError(Ingress.spec.rules[0].http.paths[1].backend): unknown field "serviceName" in io.k8s.api.networking.v1.IngressBackend, ValidationError(Ingress.spec.rules[0].http.paths[1].backend): unknown field "servicePort" in io.k8s.api.networking.v1.IngressBackend, ValidationError(Ingress.spec.rules[0].http.paths[1]): missing required field "pathType" in io.k8s.api.networking.v1.HTTPIngressPath]; if you choose to ignore these errors, turn validation off with --validate=false

My question is for k8s 1.22. How do I validate the template for networking api version and a sample template? In exam we don’t Google to use for template search.

unnivkn:
Hi @ameya agashe pleas create a simple ingress resource using imperative command & see what api version it is having. fyi: https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#-em-ingress-em-

unnivkn:
https://kubernetes.io/docs/concepts/services-networking/ingress/

ameya agashe:
Good lead @unnivkn!