apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: rabbitmq
spec:
  selector:
    matchLabels:
      app: rabbitmq
  serviceName: "rmq-cluster"
  replicas: 3
  template:
    metadata:
      labels:
        app: rabbitmq
    spec:
      serviceAccountName: rabbitmq
      terminationGracePeriodSeconds: 10
      containers:
      - name: rabbitmq
        image: eu.gcr.io/{{PROJECT-ID}}/rabbitmq:{{COMMIT}}
        ports:
        - name: queue-port
          containerPort: 5672
        - name: management-port
          containerPort: 15672
        - name: cluster-port
          containerPort: 4369
        - name: dist-port
          containerPort: 25672
        env: 
        - name: RABBITMQ_DEFAULT_USER
          value: "rmq-mgmt"
        - name: RABBITMQ_DEFAULT_PASS
          value: "GbSBDhpUfIPkpTSEO8SouiUaaA5x479X"
        - name: RABBITMQ_ERLANG_COOKIE
          value: "x8KQ67SZ6GtxxwRxw7VOcwy8KXg3jX5z"
        - name: RABBITMQ_USE_LONGNAME
          value: "true"
        - name: POD_IP
          valueFrom:
            fieldRef:
              fieldPath: status.podIP
        - name: RABBITMQ_NODENAME
          value: "rabbit@$(POD_IP)"
        volumeMounts:
        - name: rabbitmq
          mountPath: /var/lib/rabbitmq
  volumeClaimTemplates:
  - metadata:
      name: rabbitmq
    spec:
      accessModes: ["ReadWriteOnce"]
      storageClassName: standard
      resources:
        requests:
          storage: 10Gi
