Closed subnetmarco closed 7 years ago
regarding dnsmasq dependency removal;
I'd like to propose the following setup;
/etc/resolv.conf
and extracts the nameserver
entries and injects those in the nginx config/etc/hosts
file is parsed.hosts
file, If found, the request is adjusted by replacing the hostname with the IP addressThis will;
Would this work? Thoughts?
base on an interval, the /etc/hosts file is parsed.
I have big doubts about this, since disk IO is blocking.
since disk IO is blocking.
Which is also why nginx doesn't provide this functionality natively. So I retract my statement at the beginning of this issue when I said:
Replacing dnsmasq is trivial. We would need to parse /etc/hosts and resolv.conf every x seconds and use that resolution to discover the IP address of the upstream server.
On a second though, it's not trivial at all. Before dnsmasq we had 8.8.8.8
as a default DNS resolver, but this is wrong for a couple of reasons:
resolv.conf
I am not 100% sure we can get rid of this dependency, and I am more inclined we could find a better way of dealing with dependencies like this with a process supervisor like discussed in #928. Thoughts?
I have big doubts about this, since disk IO is blocking.
correct hadn't thought a bout that one. Alternatively, parse at startup (in master) and use nginx signals to reload. The way it was intended. Even better as it sticks to the standard way of working with nginx.
On a second though, it's not trivial at all. Before dnsmasq we had 8.8.8.8 as a default DNS resolver, but this is wrong for a couple of reasons:
Not if you want a fully compliant resolver. But two important things we do want to achieve are;
And those can be achieved. We need to document that anything more advanced needs a custom DNS.
And specifically; when no nameservers are found in the resolv.conf
file, we need to issue a big warning in the startup log.
especially dropping the responsibility of managing the dns service is important imo
can i chime in with a possibly stupid question? why is the default not like nginx? that is, to resolve hostnames on start using the local /etc/hosts
file and resolv.conf
configuration?
and another possibly stupid question: why not use inotify to monitor (instead of poll) the local /etc/hosts
file and resolv.conf
configuration?
dnsmasq was removed https://github.com/Mashape/kong/blob/master/CHANGELOG.md#changed-2
Serf removal is underway and will appear in a future release candidate.
Currently Kong relies on dnsmasq and Serf for the following operations:
/etc/hosts
andresolv.conf
(which nginx doesn't natively support)This functionalities can be written in pure Lua, thus removing the third-party dependencies and simplifying development and deployment of Kong.
Replacing dnsmasq is trivial. We would need to parse
/etc/hosts
andresolv.conf
everyx
seconds and use that resolution to discover the IP address of the upstream server.Replacing Serf is a little bit harder, since we would have to build a brand new Lua implementation (I couldn't find any existing library doing this), but having this dependency as a library would fix the current design and all its associated problems. On the bright side of this we wouldn't need to implement all the features that Serf currently implementes, but just the subset that we are using.