Allow the default service account to read pods data, by adding a role binding:
TODO: Now the yaml works only for the dev1
namespace, how can I make it more generic?
kubectl apply -f ./add-read-pods-binding.yaml
Deploy the VerneMQ StatefulSet:
kubectl apply -f ./vernemq.yaml
TODO: Mount volumes...
Check cluster running this command inside one of the pod:
vmq-admin cluster show
More info: https://hub.docker.com/r/erlio/docker-vernemq/
Sample node.js testing app:
npm install mqtt
import * as mqtt from "mqtt"
const client = mqtt.connect('mqtt://YOUR-LOADBALANCER-IP')
client.on('connect', function () {
console.log("Connected...")
client.subscribe('presence', (err) => {
if (err) {
console.error("Failed to subscribe");
return;
}
client.publish('presence', 'Hello mqtt');
});
});
client.on("error", function(err) {
console.error(err);
});
client.on('message', function (topic, message) {
// message is Buffer
console.log(topic, message.toString())
client.end()
});