nginx-loadbalancer-kubernetes
nginx-loadbalancer-kubernetes copied to clipboard
Make upstreams route only to nodes known to contain ingress pods
Is your feature request related to a problem? Please describe
Currently NLK populates the host/port of all nodes in the cluster to the NGINX upstream
block. If a request goes to a node that does not have a pod running the NGINX Ingress controller, kube-proxy
will take care of getting it there. However, it seems that it would be better to route the request to the ingress-containing node to begin with since we have that information.
Describe the solution you'd like
When we receive updates about a new configuration of the cluster/controller, NLK should compare the node list to the locations of the ingress pods, and only send those upstreams to NLK. That means upstreams should change when:
- We scale the ingress
- When the ingress is deployed for the first time
- When we add nodes to the cluster only if this creates changes to the ingress pods
- Ingress pods are rebalanced across nodes.
If there are no nodes containing ingress pods, perhaps it is best then to send all notes and dispatch an event about the trouble. That way at least we consistently send traffic to the cluster and don't drop it if we have some bug/race condition in figuring out ingress pod assignments.
Describe alternatives you've considered
The current operation works fine due to kube-proxy picking up the slack. I don't see any other ways of achieving this.