diff --git a/etc/emq.conf b/etc/emq.conf index 4de7491a2..cf33692db 100644 --- a/etc/emq.conf +++ b/etc/emq.conf @@ -8,50 +8,63 @@ ##-------------------------------------------------------------------- ## Cluster name -cluster.name = emqcluster +cluster.name = emqcl -## Cluster discovery strategy: manual | static | mcast | dns | etcd -cluster.discovery = mcast +## Cluster discovery strategy: manual | static | mcast | dns | etcd | k8s +cluster.discovery = etcd ## Cluster Autoheal: on | off -cluster.autoheal = off +cluster.autoheal = on ## Clean down node of the cluster -cluster.clean_down = 1h +cluster.autoclean = 5m ##-------------------------------------------------------------------- ## Cluster with static node list -## cluster.static.seeds = emq1@127.0.0.1,emq@127.0.0.1 +## cluster.static.seeds = ekka1@127.0.0.1,ekka2@127.0.0.1 ##-------------------------------------------------------------------- ## Cluster with multicast cluster.mcast.addr = 239.192.0.1 -cluster.mcast.ports = 4369,4370,4371 +cluster.mcast.ports = 4369,4370 cluster.mcast.iface = 0.0.0.0 -cluster.mcast.ttl = 1 +cluster.mcast.ttl = 255 cluster.mcast.loop = on ##-------------------------------------------------------------------- ## Cluster with DNS -## cluster.dns.name = localhost +cluster.dns.name = localhost -## cluster.dns.app = emqx +cluster.dns.app = emqx ##-------------------------------------------------------------------- ## Cluster with Etcd -## cluster.etcd.addr = http://127.0.0.1:2367 +cluster.etcd.server = http://127.0.0.1:2379 -## cluster.etcd.prefix = ekkacluster +cluster.etcd.prefix = emqcluster -## cluster.etcd.node_ttl = 1h +cluster.etcd.node_ttl = 1m + +##-------------------------------------------------------------------- +## Cluster with k8s + +cluster.k8s.apiserver = http://10.110.111.204:8080 + +cluster.k8s.service_name = emq + +## Address Type: ip | dns +cluster.k8s.address_type = ip + +## The Erlang application name +cluster.k8s.app_name = emq ##-------------------------------------------------------------------- ## Node Args diff --git a/priv/emq.schema b/priv/emq.schema index 5094691f5..293ec67a4 100644 --- a/priv/emq.schema +++ b/priv/emq.schema @@ -7,7 +7,7 @@ %% @doc Cluster name {mapping, "cluster.name", "ekka.cluster_name", [ - {default, emqcluster}, + {default, ekka}, {datatype, atom} ]}. @@ -17,16 +17,15 @@ {datatype, atom} ]}. +%% @doc Clean down node from the cluster +{mapping, "cluster.autoclean", "ekka.cluster_autoclean", [ + {datatype, {duration, ms}} +]}. + %% @doc Cluster autoheal {mapping, "cluster.autoheal", "ekka.cluster_autoheal", [ {datatype, flag}, - {default, on} -]}. - -%% @doc Clean down node from the cluster -{mapping, "cluster.clean_down", "ekka.cluster_clean_down", [ - {datatype, {duration, ms}}, - {default, "1h"} + {default, off} ]}. %%-------------------------------------------------------------------- @@ -81,7 +80,6 @@ %%-------------------------------------------------------------------- %% Cluster with DNS - {mapping, "cluster.dns.name", "ekka.cluster_discovery", [ {datatype, string} ]}. @@ -93,7 +91,7 @@ %%-------------------------------------------------------------------- %% Cluster with etcd -{mapping, "cluster.etcd.addr", "ekka.cluster_discovery", [ +{mapping, "cluster.etcd.server", "ekka.cluster_discovery", [ {datatype, string} ]}. @@ -106,6 +104,25 @@ {default, "1m"} ]}. +%%-------------------------------------------------------------------- +%% Cluster with K8s + +{mapping, "cluster.k8s.apiserver", "ekka.cluster_discovery", [ + {datatype, string} +]}. + +{mapping, "cluster.k8s.service_name", "ekka.cluster_discovery", [ + {datatype, string} +]}. + +{mapping, "cluster.k8s.address_type", "ekka.cluster_discovery", [ + {datatype, {enum, [ip, dns]}} +]}. + +{mapping, "cluster.k8s.app_name", "ekka.cluster_discovery", [ + {datatype, string} +]}. + {translation, "ekka.cluster_discovery", fun(Conf) -> Strategy = cuttlefish:conf_get("cluster.discovery", Conf), Filter = fun(Opts) -> [{K, V} || {K, V} <- Opts, V =/= undefined] end, @@ -127,9 +144,14 @@ [{name, cuttlefish:conf_get("cluster.dns.name", Conf)}, {app, cuttlefish:conf_get("cluster.dns.app", Conf)}]; (etcd) -> - [{addr, string:tokens(cuttlefish:conf_get("cluster.etcd.addr", Conf), ",")}, + [{server, string:tokens(cuttlefish:conf_get("cluster.etcd.server", Conf), ",")}, {prefix, cuttlefish:conf_get("cluster.etcd.prefix", Conf, "emq")}, {node_ttl, cuttlefish:conf_get("cluster.etcd.node_ttl", Conf, 60)}]; + (k8s) -> + [{apiserver, cuttlefish:conf_get("cluster.k8s.apiserver", Conf)}, + {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)}]; (manual) -> [ ] end,