apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: event-bus
spec:
  serviceName: event-bus
  selector:
    matchLabels: 
      event-bus: rabbitmq
  template:
    metadata:
      labels:
        event-bus: rabbitmq
        system: event-bus
    spec:
      containers:
      - name: event-bus
        image: rabbitmq:3-management
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 5672
        resources:
          limits:
            memory: "1Gi"
            cpu: "500m"
        env:
        - name: RABBITMQ_DEFAULT_USER
          valueFrom:
            configMapKeyRef:
              name: environment-settings
              key: event-bus-user
        - name: RABBITMQ_DEFAULT_PASS
          valueFrom:
            secretKeyRef:
              name: environment-secrets
              key: event-bus-password
        volumeMounts:
        - name: event-bus-data
          mountPath: /var/lib/rabbitmq/mnesia
      volumes:
      - name: event-bus-data
        persistentVolumeClaim:
          claimName: event-bus-data