Skip to main content
Version: Mosquitto 2.7

Single Node

To set up a single Mosquitto broker and Management Center using Helm charts, you'll first need a Kubernetes environment. For deploying kubernetes on a single host, Minikube is an excellent choice. Minikube is a lightweight Kubernetes distribution designed for local development and testing (Discussed in Introduction section).

Single node setup would deploy a single Mosquitto broker and a Management-Center pod as a deployment entity.

Recommended Setup

  1. 1 MMC and 1 Mosquitto Broker (single host)

Installation

Before proceeding with the actual installation of Mosquitto brokers we would need certain dependencies as a prerequisites for Minikube Kubernetes setup. You can install those dependencies using the install-dependencies.sh file in the shared directory. You can find the required dependencies installation file based on your host configuration.

  1. Setup the folder on your local machine:

    • Copy or setup the mosquitto-2.7-mmc-2.7-singlenode-kubernetes repository to your local machine. Also make sure to create a directory inside the repository named license that contains the license.lic file we provided you.
    • If you face any permission issues then make sure all the data directories have adequate privilges so that mosquitto kubernetes pods can create additional directories inside these data directories. If you face any issues like permission denied you can try giving the 1000 ownership to all the relevant data dir using following command: sudo chown -R 1000:1000 /home/<user>/mosquitto-2.7-mmc-2.7-singlenode-kubernetes/mosquitto/data
  2. Setup Minikube Kubernetes Setup

  3. Change Directory:

    • Navigate to the project directory (i.e single-node). cd mosquitto-2.7-mmc-2.7-singlenode-kubernetes/kubernetes/single-node
  4. Install Helm Chart:

    • Use the following helm install command to deploy the setup to your Kubernetes cluster. Replace <release-name> with the desired name for your Helm release and <namespace> with your chosen Kubernetes namespace:
      helm install <release-name> mosquitto-single-node-0.1.0.tgz  --set repoPath=$HOME -n <namespace>
    • repoPath: Set the repoPath flag to the path where this repo was cloned. The above command expects it to be at $HOME.
    • namespace: Set it to the namespace of your deployment.
    • Note: Ensure that you have a running Kubernetes cluster set up to run this deployment. We recommend setting up the kubernetes cluster using Minikube. You can also use our installation script to set up Kubernetes cluster. To setup the kubernetes cluster, follow the instructions in Kubernetes Cluster Setup.
    • Note: If you want to deploy the setup in a different namespace, make sure to pass a seperate flag --set namespace=<your-custom-namespace> along with the helm installation command
  5. Open Applications:

  • kubectl get nodes -o wide
  • Get the node ip from the above command. This would not same as your host as Minikube setups a hypervisor between your host and Kubernetes pods.Usually the IP of minikube is 192.168.49.2.
  • http://<"node-ip">:31021 (Open on your browser )
  • Note: If MMC is not loading then you can following command: minikube service mmc -n <namespace>
  1. To uninstall the setup: helm uninstall <release-name> -n <namespace>
  2. To delete the minikube setup and delete all config: minikube stop && minikube delete

Kubernetes Cluster Setup

If you need to set up a Kubernetes cluster, you can use our installation script (recommended). If you plan on using your own cluster, you can skip to step 3. Follow these steps:

Dependencies and Prerequisites:

  • Docker
  • Minikube
  • Helm
  1. Choose Architecture Folder:

    • Depending on your host architecture, navigate to the corresponding folder:
      • For Debian AMD64:
        cd mosquitto-2.7-mmc-2.7-singlenode-kubernetes/kubernetes/single-node/debian_amd64
  2. Install Pre-requisites:

    • Run the following command to install the necessary dependencies on the host:
      bash  install-dependencies.sh
  3. Setup Kubernetes: IMPORTANT

    • Execute the setup script to configure Kubernetes:
      bash setup.sh
      • Follow the instructions of this file. This would install Minikube, create configmap for mosquitto.conf, create configmaps for your license file. Make sure you have placed your license file in the required folder before running this script.
      • The default namespace for installation is single-node. You can change the namespace through the setup script..
  4. Setup Kubernetes Secrets:

    • This step is required for kubernetes to pull required docker images from the registry. You can set the secrets using the following command:
      kubectl create secret docker-registry  mosquitto-pro-secret  --docker-server=registry.cedalo.com --docker-username=<username> --docker-password=<password>  --docker-email=<email> -n <namespace>
    • namespace: namespace should be the same as the one you selected or entered while running the setup.sh.
    • docker-username: Your docker username
    • docker-password: Your docker password
    • docker-email: Email registered for accessing docker registry
  5. You can monitor the running pods using the following command: kubectl get pods -o wide -n <namespace>

Further Useful Commands:

  • If you want to change mosquitto.conf. Make the required changes in mosquitto.conf then delete the configmap and create a new one. Make sure to uninstall the deployment before making the change.
  • You can uninstall the setup using the following command: helm uninstall <release-name> -n <namespace>
  • To delete the configmap: kubectl delete configmap mosquitto-config -n <namespace>
  • To reconfigure the configmap (after making changes to mosquitto.conf): kubectl create configmap mosquitto-config -n $namespace --from-file=<path-to-mosquitto.conf>
  • If you want to customize the deployments, you can unzip the package using: tar -xzvf mosquitto-single-node-0.1.0.tgz
  • Make the changes and repackage the folder mosquitto-multi-node-single-host using: helm package mosquitto-single-node

Usage

Once the installation is complete, you can start using the multi-node Mosquitto broker. Be sure to check the Mosquitto documentation for further details on configuring and using the broker.