We are actively expanding the configurations available in our new Platform Operator. In the interim, if you have specific requirements to incorporate additional configurations not covered by the platform's default settings, this guide is designed to assist you.
This step-by-step guide provides instructions on how to override HiveMQ's config.xml when the required configurations are not available in the platform's values.yaml. This is particularly useful when you need to customize specific HiveMQ configurations not exposed to the platform's default settings.
Examples: https://docs.hivemq.com/hivemq/latest/user-guide/configuration.html#default or https://docs.hivemq.com/hivemq/latest/user-guide/configuration.html#mqtt-config or internal options, etc.
Prerequisites:
Helm version v3+
Running Kubernetes cluster version 1.18.0 or higher
kubectl latest version
...
In the HiveMQ Platform Helm chart, it is possible to override the default HiveMQ config.xml from using a config mapconfigMap.
Prepare the config map manifest,
hivemq-configuration-override.yml. Note that the config map contains two keys:config.xmlandtracing.xml.
Create the config mapCode Block language yaml # Source: hivemq-platform/templates/hivemq-configuration.yml apiVersion: v1 kind: ConfigMap metadata: name: hivemq-configuration-broker-override namespace: hivemq data: # noinspection XmlPathReference config.xml: |- <?xml version="1.0"?> <hivemq xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="config.xsd"> <listeners> <tcp-listener> <port>1883</port> <bind-address>0.0.0.0</bind-address> </tcp-listener> <tls-websocket-listener> <port>8000</port> <bind-address>0.0.0.0</bind-address> <path>/mqtt</path> <tls> <keystore> <path>/path/to/broker-keystore.jks</path> <password>${ENV:BROKER_KEYSTORE_PASS}</password> <private-key-password>${ENV:BROKER_KEY_PASSPHRASE}</private-key-password> </keystore> <client-authentication-mode>NONE</client-authentication-mode> </tls> </tls-websocket-listener> </listeners> <cluster> <transport> <tcp> <bind-address>0.0.0.0</bind-address> <bind-port>7000</bind-port> </tcp> </transport> <enabled>true</enabled> <discovery> <extension/> </discovery> </cluster> <!-- required and should not be configured different --> <health-api> <enabled>true</enabled> <listeners> <http> <port>8889</port> <bind-address>0.0.0.0</bind-address> </http> </listeners> </health-api> <control-center> <listeners> <http> <port>8080</port> <bind-address>0.0.0.0</bind-address> </http> </listeners> </control-center> </hivemq> tracing.xml: |- <?xml version="1.0" encoding="UTF-8" ?> <tracing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="tracing.xsd"> <context-propagation> <outbound-context-propagation> <enabled>false</enabled> </outbound-context-propagation> </context-propagation> <sampling> <publish-sampling> <enabled>true</enabled> </publish-sampling> </sampling> </tracing>Create the config map.
Code Block language bash kubectl apply -f hivemq-configuration-override.yml --namespace hivemq
Optionally, you can create a configMap directly with your ready config.xml with the following command.
| Code Block | ||
|---|---|---|
| ||
kubectl |
...
create |
...
configmap hivemq-configuration-broker-override |
...
--from-file path/to/config.xml --namespace hivemq |
Update the HiveMQ Platform values.yaml, disable to create the config map (
create: false), and specify the new name of the config map (name: "hivemq-configuration-broker-override").Code Block language yaml config: create: false name: "hivemq-configuration-broker-override" overrideHiveMQConfig: "" overrideStatefulSet: "" overrideInitContainers: ""Update the HiveMQ Platform.
Code Block language yaml helm upgrade broker --install hivemq/hivemq-platform --values values.yamlSpecify the updated in the step 3 values.yaml in the
--values values.yamlCheck the broker pods status and ensure that all pods are running and all containers are ready.
Code Block language bash kubectl get pods --namespace hivemq -o wideReview the content of the
config.xmlfile on the broker pod and make sure that it is overridden:Code Block language bash kubectl exec broker-0 -c hivemq -- cat conf-k8s/config.xmlReview the
hivemq.logto confirm thatconfig.xmlis loaded successfully.Code Block kubectl logs <pod name> -n <namespace>Perform Quick Tests:
Utilize the MQTT CLI to conduct quick tests to verify changes
| Info |
|---|
Note: Helm values.yaml broker configurations will be overridden when custom config.xml is used, and services must be configured in Helm values.yaml as per custom config.xml to avoid conflicts. |
\uD83D\uDCCB Related articles
...