Enable load balancer
Open values.yaml and search for port 1883 under hivemq.ports.port
ports: - name: "mqtt" port: 1883 expose: true patch: - '[{"op":"add","path":"/spec/selector/hivemq.com~1node-offline","value":"false"},{"op":"add","path":"/metadata/annotations","value":{"service.spec.externalTrafficPolicy":"Local"}}]' # If you want Kubernetes to expose the MQTT port to external traffic # - '[{"op":"add","path":"/spec/type","value":"LoadBalancer"}]'
Uncomment and expose the loadbalancer
ports: - name: "mqtt" port: 1883 expose: true patch: - '[{"op":"add","path":"/spec/selector/hivemq.com~1node-offline","value":"false"},{"op":"add","path":"/metadata/annotations","value":{"service.spec.externalTrafficPolicy":"Local"}}]' # If you want Kubernetes to expose the MQTT port to external traffic - '[{"op":"add","path":"/spec/type","value":"LoadBalancer"}]'
Save the file and apply the changes
helm upgrade hivemq --install hivemq/hivemq-operator --values values.yaml
Check if the service for port 1883 has an external IP address now (in our case its hivemq-hivemq-mqtt)
kubectl get services
In case the external IP is not visible, you can uninstall hivemq and reinstall it again.
Uninstall HiveMQ
helm uninstall hivemq
Reapply the changes
helm upgrade hivemq --install hivemq/hivemq-operator --values values.yaml
Connect To Your HiveMQ Cluster
Once your HiveMQ cluster is up and running, you are ready to connect clients to the cluster with the MQTT-CLI.
To obtain the exposed ENDPOINT
of the created load balancer on which clients connect to your cluster, enter:
kubectl get hivemq-clusters
Output similar to the following displays:
$ kubectl get hivemq-clusters NAME SIZE IMAGE VERSION STATUS ENDPOINT MESSAGE hivemq 3 hivemq/hivemq4 k8s-4.24.0 Running 20.52.209.35 Live updates completed successfully
To start up the MQTT-CLI in shell mode, enter:
mqtt sh
In shell-mode, connect a new MQTT client to your HiveMQ cluster on the previously acquired endpoint address:
con -h 20.52.209.35
You have now successfully connected a new MQTT client to a HiveMQ cluster hosted on Azure.
To learn more ways to interact with HiveMQ, see the MQTT-CLI documentation.