Kubernetes Ingress difference of path/backend specification

2/18/2020

What's the difference between these two specs in my ingress resource. Do they perform the same thing? When do I use which type?

spec:
  rules:
  - host: {{ .Values.Subdomain }}{{ .Values.Domain }}
    http:
      paths:
        - path: /api
          backend:
            serviceName: {{ .Values.ServiceName }}
            servicePort: 80

And:

spec:
  rules:
  - host: {{ .Values.Subdomain }}{{ .Values.Domain }}
    http:
      paths:
      - backend:
          serviceName: {{ .Values.ServiceName }}
          servicePort: 80
        path: /api
-- binaryguy
kubernetes
kubernetes-ingress

2 Answers

2/18/2020

These two specifications are the same in YAML - the order of items is not relevant.

-- koe
Source: StackOverflow

2/18/2020

There is no difference. The paths field is a list of maps(dictionary), where each map consists of path and backend field. Within a map, the order of fields doesn't matter which is the case in your two templates.

-- anmol agrawal
Source: StackOverflow