Support K8S hostname auto discovery cluster

This commit is contained in:
turtled 2019-07-18 16:16:35 +08:00 committed by Shawn
parent eb68ce77b6
commit caf6dab808
3 changed files with 15 additions and 4 deletions

View File

@ -145,7 +145,7 @@ cluster.autoclean = 5m
## The address type is used to extract host from k8s service.
##
## Value: ip | dns
## Value: ip | dns | hostname
## cluster.k8s.address_type = ip
## The app name helps build 'node.name'.
@ -153,6 +153,11 @@ cluster.autoclean = 5m
## Value: String
## cluster.k8s.app_name = emqx
## The suffix added to hostname get from k8s service, only valid if cluster.k8s.address_type set to hostname
##
## Value: String
## cluster.k8s.hostname_suffix =
## Kubernates Namespace
##
## Value: String

View File

@ -129,7 +129,7 @@
]}.
{mapping, "cluster.k8s.address_type", "ekka.cluster_discovery", [
{datatype, {enum, [ip, dns]}}
{datatype, {enum, [ip, dns, hostname]}}
]}.
{mapping, "cluster.k8s.app_name", "ekka.cluster_discovery", [
@ -140,6 +140,11 @@
{datatype, string}
]}.
{mapping, "cluster.k8s.hostname_suffix", "ekka.cluster_discovery", [
{datatype, string},
{default, ""}
]}.
{translation, "ekka.cluster_discovery", fun(Conf) ->
Strategy = cuttlefish:conf_get("cluster.discovery", Conf),
Filter = fun(Opts) -> [{K, V} || {K, V} <- Opts, V =/= undefined] end,
@ -176,7 +181,8 @@
{service_name, cuttlefish:conf_get("cluster.k8s.service_name", Conf)},
{address_type, cuttlefish:conf_get("cluster.k8s.address_type", Conf, ip)},
{app_name, cuttlefish:conf_get("cluster.k8s.app_name", Conf)},
{namespace, cuttlefish:conf_get("cluster.k8s.namespace", Conf)}];
{namespace, cuttlefish:conf_get("cluster.k8s.namespace", Conf)},
{hostname_suffix, cuttlefish:conf_get("cluster.k8s.hostname_suffix", Conf, "")}];
(manual) ->
[ ]
end,

View File

@ -4,7 +4,7 @@
{gproc, "0.8.0"}, % hex
{replayq, "0.1.1"}, %hex
{esockd, "5.5.0"}, %hex
{ekka, {git, "https://github.com/emqx/ekka", {tag, "v0.5.7"}}},
{ekka, {git, "https://github.com/emqx/ekka", {branch, "master"}}},
{gen_rpc, {git, "https://github.com/emqx/gen_rpc", {tag, "2.3.1"}}},
{cuttlefish, {git, "https://github.com/emqx/cuttlefish", {tag, "v3.0.0"}}}
]}.