Ingress multiple paths vs multiple ingresses

I assume that multiple ingresses would cost more (?).

  • Multiple ingress controllers like nginx-ingress: Yes, it would cost more if you are using an external load balancer and a cloud provider like AWS, GCP or Azure because you will be using as many load balancers as ingress controller. It would not cost more if you are using just a ClusterIP (accessing within the cluster) and it will vary if you are using a NodePort service to expose it.
  • Multiple Ingress Kubernetes resources: No it would not cost more if you are using the same ingress controller.

When I define: - path: /api in the ingress resource, I receive a 404 on GET request.

This means it's going to the default backend and likely because of this annotation nginx.ingress.kubernetes.io/rewrite-target: /. Essentially, that's stripping the /api from your request that is going to your backend. If you want to preserve the path, I suggest you remove the annotation.

You can always check the nginx ingress controller nginx.conf file with something like:

$ kubectl cp <pod-where-nginx-controller-is-running>:nginx.conf .
$ cat nginx.conf

You don't pay per Ingress resource because an Ingress resource just defines a routing rule. Putting all the routing definitions in one Ingress file and splitting into different Ingress files can actually just result in the same rules being applied. See ingress ingress-nginx - create one ingress per host? Or combine many hosts into one ingress and reload?

Tags:

Kubernetes