---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: rabbitmq
  namespace: iot
  labels:
    app: rabbitmq
spec:
  replicas: 1
  selector:
    matchLabels:
      app: rabbitmq
  strategy:
    rollingUpdate:
      maxUnavailable: 0
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: rabbitmq
    spec:
      containers:
      - name: rabbitmq
        image: rabbitmq:3.7.22-rc.1-management-alpine
        env:
        - name: RABBITMQ_USER
          valueFrom:
            secretKeyRef:
              name: rabbitmq
              key: user
        - name: RABBITMQ_PASS
          valueFrom:
            secretKeyRef:
              name: rabbitmq
              key: password
        lifecycle:
          postStart:
            exec:
              command: ["/bin/sh", "-c", "sleep 15; rabbitmqctl add_user user bitnami;\
                  \ rabbitmqctl set_permissions user \".*\" \".*\" \".*\";"]
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 4369
          name: discovery
          protocol: TCP
        - containerPort: 5672
          name: amqp
          protocol: TCP
        - containerPort: 25672
          name: internode
          protocol: TCP
        - containerPort: 15672
          name: httpapi
          protocol: TCP
      imagePullSecrets:
      - name: regcred
