Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Create a Namespace for the HiveMQ/Postgres deployment. You can skip this step you want to run everything in “default” namespace.

    Execute the following command to create a namespace:

    Code Block
    languagebash
    kubectl create namespace <namespace name>

    Switch to the newly created namespace:

    Code Block
    languagebash
    kubectl config set-context --current --namespace=<namespace name>
  2. Deploy Postgres

    Add the Bitnami Helm repository:

    Code Block
    languagebash
    helm repo add bitnami <https://charts.bitnami.com/bitnami>

    Create a postgres_values.yaml file to configure Postgres deployment:

    Code Block
    languageyaml
    global:
      storageClass: "rook-ceph-block"
      postgresql:
        auth:
          password: password
          postgresPassword: password
          username: admin
    
    primary:
      initdb:
        scriptsConfigMap: ese-db-init

    Create a ConfigMap called ese-db-init containing the ese-db-init.sql script, which creates tables and inserts necessary data for testing purposes:

    View file
    nameese-db-init.sql
    View file
    namepermissions.sql

    Code Block
    languagebash
    kubectl create configmap ese-db-init --from-file ese-db-init.sql --from-file permissions.sql

    Deploy Postgres using Helm:

    Code Block
    languagebash
    helm upgrade postgres --install bitnami/postgresql --values postgres_values.yaml

    Verify the status of the pod:

    Code Block
    languagebash
    kubectl get pods

    If an error occurs, check the pod logs:

    Code Block
    languagebash
    kubectl logs <pod name>

    Connect to the Postgres pod to verify the connection:

    Code Block
    languagebash
    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;

...