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:
Helm version v3+
Running Kubernetes cluster version 1.18.0 or higher
kubectl latest version
Instructions
Deploy PostgreSQL: (This step is optional if you already have a running Postgres database with all required tables and data).
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 thecreate-table.sql
script this file is located insidehivemq-postgresql-extension/conf/examples/
, which creates required tables.kubectl create configmap postgresql-db-init --from-file create-table.sql
Deploy Postgres using Helm:
helm upgrade postgres --install bitnami/postgresql --values postgres_values.yaml
Verify the status of the pod:
kubectl get pods
If an error occurs, check the pod logs:
kubectl logs <pod name>
Connect to the Postgres pod to verify the connection:
psql --host 127.0.0.1 -U postgres -d postgres -p 5432
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;
Deploy HiveMQ with PostgreSQL extension
Generate hivemq_values.yaml:
Deploy HiveMQ using the HiveMQ Platform and generate the
hivemq_values.yaml
file:helm show values hivemq/hivemq-platform > hivemq_values.yaml
Configure PostgreSQL extension License:
Follow the specific steps outlined for configuring the HiveMQ and PostgreSQL extension license. Setting Up HiveMQ License for Your HiveMQ Cluster using HiveMQ Platform Operator
Create config.xml for PostgreSQL extension:
Examples of the
config.xml
file are in the extension folder underconf/examples
.Configure the
postgresql
with your database name, host, username, and password.Configure the
<mqtt-to-postgresql-route>
Please refer to the example:
<hivemq-postgresql-extension xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="config.xsd"> <postgresqls> <postgresql> <id>my-postgresql-id</id> <host>postgres-postgresql</host>