VerneMQ cluster auto join on GKE

I’m new in VerneMQ and K8s. I have a working VerneMQ docker image (made from source) deployed with 2 replicas on GKE. They work fine, but i have to manualy connect into one container and ejecute:

vmq-admin cluster join discovery-node=<OtherClusterNode>

so they can find each other and join in a VerneMQ Cluster.

Is there a way they can discover for each other and join in a cluster when container start?, not manually each time i rebuild the containers

I was thinking in fixing somehow each verne node name and running a script (only in one container) to join the cluster, but it feels hacky.

My main problem is that in the meantime between containers starts and the execution of the vmq-admin cluster join command, i have 2 independent vernemq servers and a subsciber may connect to a diferent server than the consumer.

My deployment yaml looks like:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: broker-verne-deployment
spec:
  replicas: 2
  selector:
    matchLabels:
      servicio: bkr-verne
  template:
    metadata:
      labels:
        servicio: bkr-verne
    spec:
      containers:
        - name: broker-verne
          image: gcr.io/<my project id>/broker-verne/master
          ports:
            - containerPort: 80
            - containerPort: 1883
            - containerPort: 8883
            - containerPort: 8888
            - containerPort: 8080
          env:
            - name: DOCKER_VERNEMQ_LOG__CONSOLE
              value: 'both'
            - name: DOCKER_VERNEMQ_LOG__CONSOLE__LEVEL
              value: 'debug'

Thanks

Source: Docker Questions

LEAVE A COMMENT