0

I am pretty novice in Kubernetes.

From the Kubernetes website, on 'host' field in ingress:

An optional host. In this example, no host is specified, so the rule applies to all inbound HTTP traffic through the IP address specified. If a host is provided (for example, foo.bar.com), the rules apply to that host.

So if I have host as 'x.y.z', path as '/my-service', then only a call like 'x.y.z/my-service/....' would be directed to the configured backend service.

If host is not set, then any call with /my-service in its url would be send to configured backend.

x.y.z/my-service/..

a.b.c/my-service/..

Both would be directed to backend.

Is my understanding correct?

halfer
  • 19,824
  • 17
  • 99
  • 186
Mandroid
  • 6,200
  • 12
  • 64
  • 134
  • Your understanding seems correct, but it seems the best way to resolve this question would be to create a couple of Ingress resources and check the behavior and see if it matches your expectations. – larsks Jun 28 '23 at 14:06
  • I actually did it, and it didnt work as I expected. So wanted to clarify. – Mandroid Jun 28 '23 at 14:07
  • If you are seeing behavior that doesn't match your expectations, it might help to include in your question your Ingress resources along with a description of how you tested things (basically, provide a [mcve]). – larsks Jun 28 '23 at 14:08
  • I actually have a detailed question asked here..https://stackoverflow.com/questions/76573422/configuring-kong-ingress-for-apache-nifi-api-on-minikube – Mandroid Jun 28 '23 at 14:10

1 Answers1

2

Generally speaking, your understanding is correct.

Host is a optional parameter that indicates to use a certain host. The usage of the host argument is also related to the DNS management of that address, so in order to use it you also need to either:

  • add the hostname into the DNS record
  • edit the /etc/hosts file (if you're running your environment locally) with the association ip hostname

After you set this up, you match any path that starts with http://host/path, e.g. http://host/path/1, http://host/path/2.

You don't match any path that either modify the host or the path prefix.

Alez
  • 1,913
  • 3
  • 18
  • 22