Configuring ingress

Hi! Im studying some kubernetes. I have already set up a 3 nodes cluster with one master without master taint so it acts as a worker. Making a simple two pages html to see how ingress works. I externally configured HAproxy as a loadbalancer. Im trying to resolve development.example.com to service1 and example.com to service2. The question is, how can i handle traffic in this case? when i configured loadblancer i used nodeip:nodeport. I need to handle this at the proxy level? srry for poor english. I got a working ingress. When i go to the url i get an NGINX error. (yeah!!). So now i have nginx access (with error) over port 80 and 443 over the three nodes. My ingress file is:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: bs-ingress
namespace: nginx-ingress
spec:
rules:

  • host: example.com.ar
    http:
    paths:
    • pathType: Prefix
      path: “/”
      backend:
      service:
      name: nginx-service
      port:
      number: 31888
  • host: development.example.com.ar
    http:
    paths:
    • pathType: Prefix
      path: “/”
      backend:
      service:
      name: login-service
      port:
      number: 31887

If i navigate to the nodes ip, i can see the service working. but i cant get the url to resolve over the correct service. Should i copy more conf files?

Solved, changed port number to 80 and worked fine. Why service port is 80 if exposed port on node (NodePort service) is exposed over 31888?

Troubleshoot it making a kubectl exec ingress-pod -it bash and then making a curl to service ports. first tried default port and wala, got the html. then tried to curl the 31888 port and then got the no connection response

the 31888 port should be used with an IP of worker node to access the app. When you expose ur service with NodePort, you have two ports. In our example: 80 for the internal cluster communication and 31888 for external communication

1 Like

It was a little bit confusing, as when routing traffic from foo.example.com to the correct app logic would tell me that ingress should point to the external app access, and not an internat cluster comunication. So do i have to expose the nodeport application to make an ingress configuration? Do i have to expose 31888 to the worker node to make foo.example.com to resolve to that app?

Now, after reading it ten times. NodePort service gives me two ports, one for outside and one for inside. Ingress works with the inside one. If i use ClusterIP service wouldnt it be the same?