Securing MQTT Broker On Kubernetes

Running Eclipse Mosquitto on Kubernetes With Helm

kadirtaskiran
cloudnesil
3 min readJan 27, 2020

--

Eclipse Mosquitto on Kubernetes in a secure way

Kubernetes is de facto standard for running dockerized applications nowadays. And at CloudNesil, we are using Kubernetes with Helm to deploy several services for internal or external applications. For an internal lab, we need to run MQTT broker in a secure way on Kubernetes with Helm. But there is no chart on official Helm Chart repo yet. So we crated a simple chart for Eclipse Mosquitto to use on Kubernetes with Kafka brokers. But in this post, we do not talk about Kubernetes, helm, chart creation, kafka or kafka brokers. In this post, we will run Eclipse Mosquitto on an existing Kubernetes cluster in a secure way with configuring values of our custom Helm chart (under development yet) and connect to MQTT Broker with self-signed certificates.

TL; DR

GitHub Repository: https://github.com/cloudnesil/eclipse-mosquitto-mqtt-broker-helm-chart

How to

Repo has helm chart files and a bash file to create self-signed certificates.

1- Clone the repo

2- Use the make-keys.sh file to create self signed certificates. make-keys.sh file content is as follow:

Go to related directory and run the bash scripts

3- Configure the values with the created cert files like as follow:

Helm chart using 1884 port for non-secure connections by default. To connect in a secure way to the broker, we configured the Eclipse Mosquitto to use 1883 port. Secure connection settings is as follow:

For detailed information about configuration of Eclipse Mosquitto you can check official documentation.

4- Deploy Eclipse Mosquitto to the Kubernetes cluster with helm

Note: Make sure nginx-ingress TCP load balancing is configured correctly for the deployed MQTT service to connect url and via 1883/1884 ports.

5- Check Eclipce Mosquitto deployed correctly, up and running also

Result should be as follow:

Eclipse Mosquitto Resources

6- Test with MQTT.fx client

MQTT.fx settings for secure connection

After configuring the certificates and profile on MQTT.fx, we can connect and test it.

According to green circle on the right corner on the top and logs, we connected securely to our MQTT broker.

Please feel free to ask questions and recommendations.

--

--