Skip to content

BYOC on Kubernetes ​

One manifest runs the ConnectMQ broker on Google Kubernetes Engine, Amazon EKS and Azure AKS. Read the BYOC overview first.

Secrets ​

bash
kubectl create secret generic connectmq --from-literal=BROKER_SECRET_KEY='<your-secret>'
kubectl create secret generic connectmq-certs --from-file=broker.pem=./broker.pem   # optional

Deployment and service ​

yaml
apiVersion: apps/v1
kind: Deployment
metadata: {name: connectmq-broker}
spec:
  replicas: 1                     # one pod per Broker ID
  strategy: {type: Recreate}      # never run two pods with the same Broker ID
  selector: {matchLabels: {app: connectmq-broker}}
  template:
    metadata: {labels: {app: connectmq-broker}}
    spec:
      securityContext: {runAsUser: 1654, runAsGroup: 1654, fsGroup: 1654}
      containers:
      - name: broker
        image: connectmqcom/broker:1.0.0
        env:
        - {name: BROKER_ID, value: my-broker-01}
        - {name: PUBLIC_BROKER_ENABLED, value: "false"}
        envFrom: [{secretRef: {name: connectmq}}]
        ports:
        - {containerPort: 1883}
        - {containerPort: 8883}
        - {containerPort: 8083}
        - {containerPort: 8084}
        resources:
          requests: {cpu: 500m, memory: 1Gi}
          limits: {memory: 2Gi}
        readinessProbe: {tcpSocket: {port: 1883}, periodSeconds: 15}
        volumeMounts: [{name: certs, mountPath: /app/certs, readOnly: true}]
      volumes:
      - name: certs
        secret: {secretName: connectmq-certs, optional: true}
---
apiVersion: v1
kind: Service
metadata: {name: connectmq-broker}
spec:
  type: LoadBalancer
  externalTrafficPolicy: Local    # keep the real client IP
  selector: {app: connectmq-broker}
  ports:
  - {name: mqtt,  port: 1883, targetPort: 1883}
  - {name: mqtts, port: 8883, targetPort: 8883}
  - {name: ws,    port: 8083, targetPort: 8083}
  - {name: wss,   port: 8084, targetPort: 8084}
bash
kubectl apply -f connectmq-broker.yaml
kubectl get service connectmq-broker   # external IP for your DNS record

Why these settings ​

SettingReason
replicas: 1, strategy: RecreateExactly one running broker per Broker ID, also during updates. For more nodes, request more Broker IDs and deploy one Deployment each.
externalTrafficPolicy: LocalKeeps the client's source IP, which quotas, flood protection and IP bans rely on.
runAsUser: 1654The image runs as a non-root user.
TCP readiness probeThe pod receives traffic only when the MQTT listener is up.

Next: Verify, update & troubleshoot.

Fully managed MQTT broker for connected devices.