# Auto Clustering

# Node Discovery and Autocluster

Erlang

EMQX's clustering is based on the Ekka library. [Ekka] (https://github.com/emqx/ekka) is a cluster management library developed for Erlang/OTP applications, supporting Erlang Node Auto-Discovery, Autocluster, and Network partition autoheal and autoclean.

EMQX supports multiple autocluster strategies:

StrategyDescription
manualCreate a cluster through manual command
staticDiscovery based on a static node list
mcastDiscovery with UDP multicast mode
dnsDiscovery based on DNS records
etcdDiscovery via etcd
k8sDiscovery via Kubernetes service

# static

Configure a fixed node list to automatically discover and create clusters:

cluster {
    discovery_strategy = static
    static {
        seeds = ["emqx@s1.emqx.io", "emqx@s2.emqx.io"] 
    }
}
1
2
3
4
5
6

# mcast

Automatically discover and create clusters based on UDP multicast:

cluster {
    discovery_strategy = mcast
    mcast {
        addr = "239.192.0.1"
        ports = [4369, 4370]
        iface = "0.0.0.0"
        ttl = 255
        loop = true
    }
}
1
2
3
4
5
6
7
8
9
10

# DNS A records

Automatically discover and create clusters based on DNS A records:

cluster {
    discovery_strategy = dns
    dns {
        name = "localhost"
        record_type = a
    }
}
1
2
3
4
5
6
7

# DNS SRV records

Automatically discover and create clusters based on DNS SRV records:

cluster {
    discovery_strategy = dns
    dns {
        name = "localhost"
        record_type = srv
    }
}
1
2
3
4
5
6
7

# etcd

Automatically discover and create clusters based on etcd (opens new window):

cluster {
    discovery_strategy = etcd
    etcd {
        server = "http://127.0.0.1:2379"
        prefix = emqcl
        node_ttl = 1m
    }
}
1
2
3
4
5
6
7
8

# kubernetes

Automatically discover and create clusters based on Kubernetes (opens new window):

cluster {
    discovery_strategy = k8s
    k8s {
        apiserver = "http://10.110.111.204:8080"
        service_name = emqx
        address_type = ip
        app_name = emqx
        suffix = "pod.local"
        namespace = default
    }
}
1
2
3
4
5
6
7
8
9
10
11

TIP

The Fannel networking plugin is not recommended for Kubernetes; the Calico networking plugin is recommended.