{{- if .Values.rabbitmq.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
  name: rabbitmq
  namespace: {{ .Values.namespace }}
spec:
  replicas: {{ .Values.rabbitmq.replicas }}
  selector:
    matchLabels:
      app: rabbitmq
  template:
    metadata:
      labels:
        app: rabbitmq
    spec:
      containers:
      - name: rabbitmq
        image: {{ .Values.rabbitmq.image }}
        env:
        - name: RABBITMQ_DEFAULT_USER
          value: "{{ .Values.rabbitmq.user }}"
        - name: RABBITMQ_DEFAULT_PASS
          value: "{{ .Values.rabbitmq.password }}"
        ports:
        - name: amqp
          containerPort: {{ .Values.rabbitmq.servicePort }}
        - name: management
          containerPort: {{ .Values.rabbitmq.managementPort }}
---
apiVersion: v1
kind: Service
metadata:
  name: rabbitmq
  namespace: {{ .Values.namespace }}
spec:
  selector:
    app: rabbitmq
  ports:
  - name: amqp
    port: {{ .Values.rabbitmq.servicePort }}
    targetPort: {{ .Values.rabbitmq.servicePort }}
  - name: management
    port: {{ .Values.rabbitmq.managementPort }}
    targetPort: {{ .Values.rabbitmq.managementPort }}
{{- end }}
