Search code examples
nginx-ingress

Kubernetes Ingress Load-Balancing


It might be a stupid question. As we know, nginx-ingress controller uses round-robin algorithm by default and the ingress traffic should be distributed to Kubernetes nodes equally. The concern is when I get ingress details, it shows me only 1 node address, even though I have 3 nodes in the cluster.

kubectl get ingress

enter image description here I read the official documentation of Nginx and it says by default round-robin handles the request. Is the ingress supposed to show all node addresses in ADDRESS column when I run kubectl get ingress command? How can I know if traffic is distributed to all nodes?

Thanks

I tried to monitor ingress traffic by each hosts on Grafana dashboard, unfortunately there's no dashboard able to do that.


Solution

  • The concern is when I get ingress details, it shows me only 1 node address, even though I have 3 nodes in the cluster.

    You should treat your Nodes addresses and the Service of type LoadBalancer address as a separate entities.

    By default in a cloud managed solutions, the Service of type LoadBalancer is requesting an IP from a cloud provider and it's routing the traffic to all of it's Nodes. Imagine it being before the actual Nodes in the whole architecture.

    A side note!

    The fact that you got the address of the Node in the Ingress could mean you are using some sort of a Kubernetes solution (K3S, K0S, MicroK8S, etc.).


    How can I know if traffic is distributed to all nodes?

    Kubernetes with it's Service resource has the ability to route the requests across all of the Nodes. Try to make a nginx Deployment (with multiple replicas) and expose it via Service of type NodePort. curl it multiple times and you will see that the response is coming from multiple Pods (spread across multiple Nodes).

    I encourage you to take a look on the following documentation:


    PS:

    As for the Grafana dashboards, have you had the chance to see this one?: