This HiveMQ extension enables you to operate elastic HiveMQ clusters with an container orchestration platform (Kubernetes, Openshift) as well as cloud environments. DNS is used as cluster discovery mechanism, which is ideal for environments that scale dynamically. HiveMQ instances are added and removed at runtime as soon as they become available via DNS. This extension is typically used with Docker and container orchestration platforms.
This extension can be used with any cloud environment / container orchestration environment that
supports service discovery using a
round-robin A record.
The extension must be unzipped and the complete extension folder must be placed into the extensions folder. After this adapt the properties to your needs as described in the Configuration chapter.
The following environment variables or property keys should be used to customize the discovery parameters.
If a properties file is provided (dnsdiscovery.properties in conf/ folder), the extension will use the key-value pairs from this file and reload the values on file changes.
The extension will attempt to load the properties file first. If it does not exist, the extension will not attempt to reload the properties and instead try to read from the environment variables on each iteration until broker shutdown.
|Environment variable||Property Key||Description||Default|
|HIVEMQ_DNS_DISCOVERY_ADDRESS||discoveryAddress||Address providing the A record for the usage as cluster node addresses||/|
|HIVEMQ_DNS_DISCOVERY_TIMEOUT||resolutionTimeout||Wait time for DNS resolution to complete in seconds.||30|
For detailed information on how to configure the DNS discovery plugin see the README file included in the download or visit the GitHub page.
The following list shows a sample round-robin A-record as expected and parsed by the extension:
This record represents a 5 node cluster on an overlay network.
This diagram shows how DNS discovery is generally implemented on container engines.
The components differ when using DNS discovery outside of container engine. When using it in conjunction with DNSaaS solutions for example, the DNS entries will be created by the orchestration solution used instead.
The container engine provides a DNS server to the containers/pods for improved caching of DNS queries as well as additional functionality like service discovery and hostnames for the containers.
This DNS server is the main endpoint the DNS discovery extension will communicate with. The DNS server responds with a predefined record which is created by the orchestration engine. The record contains the list of containers/pods in the cluster, which HiveMQ will then use to discover the other nodes.
Most container orchestration environments support this type of discovery. See the following list for some examples:
More information on using the discovery mechanisms listed above can be found in the DNS discovery image README.
To implement your own solution for this discovery method, you must either provide your HiveMQ deployment with
To use DNS discovery on Kubernetes, you will generally need a headless service pointing to the HiveMQ deployment,
similar to the following configuration:
Note: The selector and name for the service are important. The selector defines which pods are listed in the resulting DNS record.
Note: The name will define the service-name of the resulting DNS record, which will be generally in the form of <service-name>.<kubernetes-namespace>.svc.<dns-domain>.
Docker swarm provides a DNS entry for service discovery by default. All you have to do is create a service, as shown in DNS discovery image README.