apiVersion: apps/v1
kind: Deployment
metadata:
  name: rabbitmq-exporter
  namespace: workflow
  labels:
    app: rabbitmq-exporter
spec:
  replicas: 1
  selector:
    matchLabels:
      app: rabbitmq-exporter
  template:
    metadata:
      labels:
        app: rabbitmq-exporter
    spec:
      containers:
        - name: rabbitmq-exporter
          image: kbudde/rabbitmq-exporter:1.0.0-RC19
          imagePullPolicy: IfNotPresent
          env:
            - name: RABBIT_URL
              value: http://rabbitmq-service.workflow.svc.cluster.local:15672
            - name: RABBIT_USER
              valueFrom:
                secretKeyRef:
                  name: rabbitmq-secret
                  key: username
            - name: RABBIT_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: rabbitmq-secret
                  key: password
            - name: PUBLISH_PORT
              value: "9419"
            - name: SKIPVERIFY
              value: "true"
          ports:
            - name: metrics
              containerPort: 9419
          resources:
            requests:
              cpu: 25m
              memory: 64Mi
            limits:
              memory: 128Mi
---
apiVersion: v1
kind: Service
metadata:
  name: rabbitmq-exporter
  namespace: workflow
  labels:
    app: rabbitmq-exporter
spec:
  type: ClusterIP
  selector:
    app: rabbitmq-exporter
  ports:
    - name: metrics
      port: 9419
      targetPort: metrics
---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: rabbitmq-exporter
  namespace: workflow
  labels:
    app: rabbitmq-exporter
    release: prometheus
spec:
  endpoints:
    - interval: 30s
      path: /metrics
      port: metrics
      relabelings:
        - action: replace
          targetLabel: cluster
          replacement: brusnika-prod
        - action: replace
          targetLabel: source_cluster
          replacement: brusnika-prod
        - action: replace
          targetLabel: rabbitmq_instance
          replacement: workflow-rabbitmq
  selector:
    matchLabels:
      app: rabbitmq-exporter
