apiVersion: apps/v1
kind: Deployment
metadata:
  name: broker
  labels:
    project: sob
    app: broker
    layer: infra
spec:
  revisionHistoryLimit: 2
  replicas: 1
  selector:
    matchLabels:
      app: broker
  template:
    metadata:
      labels:
        project: sob
        app: broker
        layer: infra
    spec:
      hostname: broker
      containers:
        - name: broker
          image: rabbitmq:3-management
          imagePullPolicy: Always
          ports:
            - containerPort: 15672
              name: http
            - containerPort: 5672
              name: amqp
          env:
            - name: RABBITMQ_DEFAULT_USER
              valueFrom:
                secretKeyRef:
                  name: sob-secret
                  key: broker-user
            - name: RABBITMQ_DEFAULT_PASS
              valueFrom:
                secretKeyRef:
                  name: sob-secret
                  key: broker-password
          volumeMounts:
            - name: broker-storage
              mountPath: /var/lib/rabbitmq
              subPath: rabbitmq-data
          resources:
            limits:
              cpu: "100m"
              memory: "512Mi"
            requests:
              cpu: "1m"
              memory: "256Mi"
      volumes:
        - name: broker-storage
          persistentVolumeClaim:
            claimName: broker-pvc
