least_conn upstream configuration issue "host not found in upstream" with Kubernetes DNS

Francis Daly francis at daoine.org
Tue Jan 5 19:55:19 UTC 2021


On Tue, Jan 05, 2021 at 01:20:34PM -0500, kpirateone wrote:

Hi there,

> 1) use ips instead of host names, not ideal due to the dynamic nature of the
> ips
> 2) maintain an upstream configuration externally and use nginx reload to
> modify the upstream as pods come online
> 
> scaling up, as stated in the referenced thread
> (https://forum.nginx.org/read.php?2,290205) is not supported in stock
> nginx.

"scaling up" by turning on upstream services on pre-configured IP:ports
is supported in nginx. Or on re-configured IP:ports.

The thing that is not supported is run-time name resolution, if I
understand things correctly.

> there doesnt seem to be any way to use a least connected policy without
> individually knowing all the hosts?

nginx needs to know what upstream IP:ports to try to connect to. There's
not really a way around that. Stock-nginx learns that list at start time.

> as in, there is no way to use least
> connected over a headless service that returns multiple ips; we must need to
> explicitly declare all known hosts?

A hostname that resolves to multiple IPs should
be fine, according to the documentation --
http://nginx.org/en/docs/http/ngx_http_upstream_module.html#server

nginx will request the name resolution at start time. Put your list of
IPs in your name server config, or in your nginx config, as you prefer.

Cheers,

	f
-- 
Francis Daly        francis at daoine.org


More information about the nginx mailing list