#
# A simple stateless prometheus instance that scrapes the contents of the
# telemeter cluster.
# 
kind: List
apiVersion: v1
items:
- kind: Service
  apiVersion: v1
  metadata:
    name: telemeter-prometheus
  spec:
    selector:
      app: telemeter-prometheus
    ports:
    - name: http
      port: 80
      targetPort: 9090
- kind: StatefulSet
  apiVersion: apps/v1
  metadata:
    name: telemeter-prometheus
  spec:
    selector:
      matchLabels:
        app: telemeter-prometheus
    template:
      metadata:
        labels:
          app: telemeter-prometheus
      spec:
        volumes:
        - name: config
          configMap:
            name: telemeter-prometheus
        - name: data
          emptyDir: {}
        containers:
        - name: prometheus
          image: openshift/prometheus:v2.2.1
          volumeMounts:
          - name: config
            mountPath: /etc/prometheus
          - name: data
            mountPath: /var/lib/prometheus
          command:
          - /usr/bin/prometheus
          - --storage.tsdb.path=/var/lib/prometheus
          - --config.file=/etc/prometheus/prom.conf
- kind: ConfigMap
  apiVersion: v1
  metadata:
    name: telemeter-prometheus
  data:
    prom.conf: |
      scrape_configs:
      - job_name: 'federate'
        scrape_interval: 15s

        honor_labels: true
        metrics_path: '/federate'

        params:
          'match[]':
            - '{__name__=~".*"}'

        dns_sd_configs:
        - names:
          - telemeter-cluster
          type: A
          port: 8081
      - job_name: 'telemeter-server'
        scrape_interval: 30s

        metrics_path: '/metrics'

        dns_sd_configs:
        - names:
          - telemeter-cluster
          type: A
          port: 8081
