How is a request routed and load balanced in Kubernetes using Ingress Controllers?

8/9/2019

I'm currently learning about Kubernetes. While the abstractions are great I'd like to understand what is actually happening under the hood with Ingress set up.

In a cloud context and using nginx ingress controller, following an external request from the load balancer to a pod, this is what I believe is happening:

  1. The request arrives at the load balancer and, using some balancing algorithm, it selects an ingress controller. Many instances of the ingress controller will likely be running in a resilient production environment.

  2. The ingress controller (nginx in this case) uses the rules exposed by the ingress service to select a node port, selecting a specific node to route to. Is there any load balancing happening by nginx here?

  3. The kubelet on the node receives this request. Depending on the set up (iptables vs ipvs) this request will be further load balanced and using the clusterip a specific pod will be selected to route to. Can this pod could exist anywhere on the cluster, on a different node to the kubelet routing it?

  4. The request is then forwarded to a specific pod and container.

Is this understanding correct?

-- Sio
kubernetes
nginx

2 Answers

8/12/2019

You should check out this guide about Kubernetes Ingress with Nginx Example. Especially the Kubernetes Ingress vs LoadBalancer vs NodePort part. The examples there should describe how it goes. The clue here is how K8S SVC NodePort works. You should also check out this guide.

Also if you are new to Kubernetes I strongly recommend to get familiar with the official documentation

Please let me know if that helped.

-- OhHiMark
Source: StackOverflow

11/13/2019

I finally found a 3 part article which went into enough detail to demystify how the networking works in Kubernetes.

https://medium.com/google-cloud/understanding-kubernetes-networking-pods-7117dd28727

-- Sio
Source: StackOverflow