Setting Up Enterprise PostgreSQL Extension with HiveMQ Platform Operator

This guide provides detailed steps for configuring the Enterprise PostgreSQL Extension with the HiveMQ Platform Operator. Ensure you meet the specified prerequisites before proceeding.

Prerequisites:

  1. Helm version v3+

  2. Running Kubernetes cluster version 1.18.0 or higher

  3. kubectl latest version


 Instructions

  1. Deploy PostgreSQL: (This step is optional if you already have a running Postgres database with all required tables and data).

    1. Add the Bitnami Helm repository:

      helm repo add bitnami https://charts.bitnami.com/bitnami

      Create a postgres_values.yaml file to configure Postgres deployment:

      global: postgresql: auth: password: password postgresPassword: password username: hivemq primary: initdb: scriptsConfigMap: postgresql-db-init

      Create a ConfigMap called postgresql-db-init containing the create-table.sql script this file is located inside hivemq-postgresql-extension/conf/examples/, which creates required tables.

      kubectl create configmap postgresql-db-init --from-file create-table.sql

      Deploy Postgres using Helm:

      Verify the status of the pod:

      If an error occurs, check the pod logs:

      Connect to the Postgres pod to verify the connection:

      Use the following commands in the Postgres shell to interact with the database:

      • \l: List the databases.

      • \c <db name>: Connect to a specific database.

      • \dt: List the tables from the connected database.

      • select * from users;

  2. Deploy HiveMQ with PostgreSQL extension

    1. Generate hivemq_values.yaml:

      Deploy HiveMQ using the HiveMQ Platform and generate the hivemq_values.yaml file:

    2. Configure PostgreSQL extension License:

      Follow the specific steps outlined for configuring the HiveMQ and PostgreSQL extension license. https://hivemq.atlassian.net/wiki/spaces/KB/pages/2672295983

    3. Create config.xml for PostgreSQL extension:

      1. Examples of the config.xml file are in the extension folder under conf/examples.

      2. Configure the postgresql with your database name, host, username, and password.

      3. Configure the <mqtt-to-postgresql-route>

      4. Please refer to the example:

    4. Create ConfigMap for PostgreSQL configuration

    5. Deploy HiveMQ Platform Operator:

    6. Edit hivemq_values.yaml: Modify the hivemq_values.yaml file to include PostgreSQL-related changes.

      1. Configure the ConfigMap name created in the previous step. Set enabled: true to enable this extension.

      2. Deploy HiveMQ:

      3. Check Pod Status:

        Verify that all hivemq pods are running.

      4. Verify Enterprise PostgreSQL Extension Start:

        Check the hivemq.log to confirm successful extension startup.

      5. Perform Quick Tests:

        Utilize the MQTT CLI to conduct quick tests.

If you intend to utilize the <statement-template>, ensure that you include the absolute path for the SQL file and verify the existence of the file.

 Related articles