Commit c2a03ce9 authored by Pedro Eduardo Trujillo's avatar Pedro Eduardo Trujillo
Browse files

Merge branch 'dev' into 'master'

Permite reubicación, revisa detalles

See merge request redmic-project/mqtt/vernemq!9
parents a1f069b3 5c19735b
Loading
Loading
Loading
Loading
+3 −6
Original line number Diff line number Diff line
@@ -6,13 +6,10 @@ include:
stages:
  - deploy

variables:
  PROJECT_PARENT_NAME: mqtt

.deploy:
  variables:
    STACK: ${PROJECT_PARENT_NAME}
    SERVICES_TO_CHECK: ${PROJECT_PARENT_NAME}_vmq-redis ${PROJECT_PARENT_NAME}_${CI_PROJECT_NAME}
    STACK: mqtt
    STATUS_CHECK_DELAY: 60
    DD_TRAEFIK_SUBDOMAIN: ${CI_PROJECT_NAME}
  environment:
    url: https://${CI_PROJECT_NAME}.${PUBLIC_HOSTNAME}
    url: https://${DD_TRAEFIK_SUBDOMAIN}.${PUBLIC_HOSTNAME}
+5 −9
Original line number Diff line number Diff line
@@ -2,28 +2,25 @@

MQTT broker.


## Client management

Check official docs about this topic here: https://docs.vernemq.com/configuration/db-auth#redis
Check official docs about this topic here: <https://docs.vernemq.com/configuration/db-auth#redis>

To interact with database, you have to run `redis-cli` inside `vmq-redis` running container.
Use `docker exec ...` or start a shell session through Portainer to access `vmq-redis`.


### List clients

```
```sh
$ redis-cli

> KEYS *

```


### Create client

```
```sh
$ redis-cli

> SET "[\"\",\"test-client\",\"test-user\"]" "{\"passhash\":\"$2a$12$WDzmynWSMRVzfszQkB2MsOWYQK9qGtfjVpO8iBdimTOjCK/u6CzJK\",\"subscribe_acl\":[{\"pattern\":\"a/+/c\"}]}"
@@ -35,12 +32,11 @@ Here, you define a new key `"[\"\",\"test-client\",\"test-user\"]"` (empty mount
This value contains a bcrypt password hash `passhash` and a list of topic patterns `subscribe_acl` with granted access for this client.

Decide a new password and generate a bcrypt hash (with 12 rounds) for it.
You can use any tool, https://www.browserling.com/tools/bcrypt for example.

You can use any tool, <https://www.browserling.com/tools/bcrypt> for example.

### Delete client

```
```sh
$ redis-cli

> DEL "[\"\",\"test-client\",\"test-user\"]"
+15 −3
Original line number Diff line number Diff line
@@ -11,8 +11,20 @@ DOCKER_VERNEMQ_ACCEPT_EULA=yes

EXTERNAL_MQTT_PORT=1883
MQTT_PORT=1883
EXTERNAL_SECURE_MQTT_PORT=8883
SECURE_MQTT_PORT=8883
EXTERNAL_MQTTWS_PORT=8080
MQTTWS_PORT=8080
PORT_MODE=ingress
REDIS_DATA_VOL_NAME=vernemq-redis-data-vol

HTTP_PORT=8888
TRAEFIK_SUBDOMAIN=vernemq

VERNEMQ_DATA_VOL_NAME=vernemq-data-vol
VERNEMQ_CONF_VOL_NAME=vernemq-conf-vol
REDIS_DATA_VOL_NAME=vernemq-redis-data-vol

VOL_TYPE=nfs4
VOL_ADDR=127.0.0.1
VOL_OPTIONS=rw,nolock,noatime,tcp,rsize=8192,wsize=8192,timeo=14
VERNEMQ_DATA_VOL_DEVICE=:/vernemq-data-vol/
VERNEMQ_CONF_VOL_DEVICE=:/vernemq-conf-vol/
REDIS_DATA_VOL_DEVICE=:/vernemq-redis-data-vol/
+21 −7
Original line number Diff line number Diff line
version: '3.5'

services:
  vmq-redis:
    deploy:
      placement:
        constraints:
          - node.hostname == ${VMQ_REDIS_PLACEMENT_CONSTRAINTS_NODE_HOSTNAME:-hostname}

volumes:
  vernemq-data-vol:
    name: ${VERNEMQ_DATA_VOL_NAME}
    driver: local
    driver_opts:
      type: ${VOL_TYPE}
      o: addr=${VOL_ADDR},${VOL_OPTIONS}
      device: ${VERNEMQ_DATA_VOL_DEVICE}

  vernemq-conf-vol:
    name: ${VERNEMQ_CONF_VOL_NAME}
    driver: local
    driver_opts:
      type: ${VOL_TYPE}
      o: addr=${VOL_ADDR},${VOL_OPTIONS}
      device: ${VERNEMQ_CONF_VOL_DEVICE}

  redis-data-vol:
    name: ${REDIS_DATA_VOL_NAME}
    driver: local
    driver_opts:
      type: ${VOL_TYPE}
      o: addr=${VOL_ADDR},${VOL_OPTIONS}
      device: ${REDIS_DATA_VOL_DEVICE}
+13 −0
Original line number Diff line number Diff line
@@ -14,6 +14,19 @@ services:
          - node.role == worker

volumes:
  vernemq-data-vol:
    name: ${VERNEMQ_DATA_VOL_NAME}
    driver: 'cloudstor:aws'
    driver_opts:
      backing: shared
      perfmode: maxio

  vernemq-conf-vol:
    name: ${VERNEMQ_CONF_VOL_NAME}
    driver: 'cloudstor:aws'
    driver_opts:
      backing: shared

  redis-data-vol:
    name: ${REDIS_DATA_VOL_NAME}
    driver: 'cloudstor:aws'
Loading