-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core) implement internal dns with loadbalancing, replace dnsmasq (…
…#1587) Implements an internal DNS resolver, some new settings and a bugfix - uses same dns resolution in Kong proxy and Kong cli - bugfix: wildcarded hostnames are now properly validated - implements SRV record resolution - implements internal (weighted) roundrobin loadbalancing on the dns records - drops dnsmasq as a dependency - implements the `retries` setting (per api) - implements the `keepalive` setting (global) - now using the `balancer_by_lua` directives - revert back to standard `pgmoon` from the workaround `pgmoon-mashape` clone - exports ipv4, ipv6 and hostname verifying and normalization to the utils module
- Loading branch information
Showing
44 changed files
with
1,104 additions
and
407 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,16 +7,17 @@ local pl_config = require "pl.config" | |
local pl_file = require "pl.file" | ||
local pl_path = require "pl.path" | ||
local tablex = require "pl.tablex" | ||
local utils = require "kong.tools.utils" | ||
local log = require "kong.cmd.utils.log" | ||
|
||
local ipv4_port_pattern = "^(%d+)%.(%d+)%.(%d+)%.(%d+):(%d+)$" | ||
|
||
local DEFAULT_PATHS = { | ||
"/etc/kong/kong.conf", | ||
"/etc/kong.conf" | ||
} | ||
|
||
local PREFIX_PATHS = { | ||
dnsmasq_pid = {"pids", "dnsmasq.pid"} | ||
; | ||
serf_pid = {"pids", "serf.pid"}, | ||
serf_log = {"logs", "serf.log"}, | ||
serf_event = {"serf", "serf_event.sh"}, | ||
|
@@ -60,6 +61,7 @@ local CONF_INFERENCES = { | |
cluster_listen_rpc = {typ = "string"}, | ||
cluster_advertise = {typ = "string"}, | ||
nginx_worker_processes = {typ = "string"}, | ||
nginx_keepalive = {typ = "number"}, | ||
|
||
database = {enum = {"postgres", "cassandra"}}, | ||
pg_port = {typ = "number"}, | ||
|
@@ -82,8 +84,7 @@ local CONF_INFERENCES = { | |
cluster_profile = {enum = {"local", "lan", "wan"}}, | ||
cluster_ttl_on_failure = {typ = "number"}, | ||
|
||
dnsmasq = {typ = "boolean"}, | ||
dnsmasq_port = {typ = "number"}, | ||
dns_resolver = {typ = "array"}, | ||
|
||
ssl = {typ = "boolean"}, | ||
admin_ssl = {typ = "boolean"}, | ||
|
@@ -206,13 +207,16 @@ local function check_and_infer(conf) | |
end | ||
end | ||
|
||
if conf.dns_resolver and conf.dnsmasq then | ||
errors[#errors+1] = "must disable dnsmasq when a custom DNS resolver is specified" | ||
elseif not conf.dns_resolver and not conf.dnsmasq then | ||
errors[#errors+1] = "must specify a custom DNS resolver when dnsmasq is turned off" | ||
if conf.dns_resolver then | ||
for _, server in ipairs(conf.dns_resolver) do | ||
local dns = utils.normalize_ip(server) | ||
if (not dns) or (dns.type ~= "ipv4") then | ||
errors[#errors+1] = "dns_resolver must be a comma separated list in the form of IPv4 or IPv4:port" | ||
break -- one error is enough | ||
This comment has been minimized.
Sorry, something went wrong.
thibaultcha
Member
|
||
end | ||
end | ||
end | ||
|
||
local ipv4_port_pattern = "^(%d+)%.(%d+)%.(%d+)%.(%d+):(%d+)$" | ||
if not conf.cluster_listen:match(ipv4_port_pattern) then | ||
errors[#errors+1] = "cluster_listen must be in the form of IPv4:port" | ||
end | ||
|
@@ -409,6 +413,10 @@ local function load(path, custom_conf) | |
|
||
log.verbose("prefix in use: %s", conf.prefix) | ||
|
||
-- initialize the dns client, so the globally patched tcp.connect method | ||
-- will work from here onwards. | ||
assert(require("kong.tools.dns")(conf)) | ||
|
||
return setmetatable(conf, nil) -- remove Map mt | ||
end | ||
|
||
|
Oops, something went wrong.
Shouldn't this be named
upstream_keepalive
?