purpose of Ingress as etc/hosts makes redirection to NodePort?

83 Views Asked by At

I actually work on a projet to understand Ingress behaviour, but i do not understand interest of using it, as etc/hosts make the job. Here is the exact workflow to understand my questioning

I have a Pod, exposed by a NodePort service, on port : 31001 the ip adress of one my nodes is : 192.168.49.2

So, when i launch this adress in a browser

http://192.168.49.2:31001/

i got my application with success.

Now i have an Ingress ressource with specification :

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: voting-domain
spec:
  ingressClassName: nginx
  rules:
  - host: vote.votingapp.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: vote-ui
            port:
              number: 80

but i have to add a line in my /etc/hosts

192.168.49.2    vote.votingapp.com

Now, when i do

http://vote.votingapp.com:31001/

it is also a success. Ok, but not due to Ingress presence but due to hosts file binding. In fact, dur to hosts file

vote.votingapp.com --> 192.168.49.2 --> resolution is done 

So, what is the interest of Ingress in my specific example ?

thanks by advance

0

There are 0 best solutions below