apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: enmasse
  name: grafana
spec:
  replicas: 1
  selector:
    matchLabels:
      app: enmasse
      name: grafana
  template:
    metadata:
      labels:
        app: enmasse
        name: grafana
    spec:
      affinity:
        nodeAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
            - weight: 1
              preference:
                matchExpressions:
                  - key: node-role.enmasse.io/operator-infra
                    operator: In
                    values:
                      - "true"
      containers:
      - name: grafana
        image: grafana/grafana:5.3.1
        imagePullPolicy: Always
        ports:
        - containerPort: 3000
          name: grafana
        volumeMounts:
        - mountPath: /etc/grafana/provisioning
          name: grafana-config
          readOnly: true
        - mountPath: /etc/grafana/dashboards
          name: grafana-dashboards
          readOnly: true
        - mountPath: /usr/share/grafana/data
          name: grafana-data
          readOnly: false
        env:
        - name: GF_INSTALL_PLUGINS
          value: "camptocamp-prometheus-alertmanager-datasource"
        - name: GF_PATHS_DATA
          value: /usr/share/grafana/data
      volumes:
      - name: grafana-config
        configMap:
          name: grafana-config
          items:
          - key: dashboard.yaml
            path: dashboards/dashboard.yaml
          - key: datasource.yaml
            path: datasources/datasource.yaml
      - name: grafana-dashboards
        configMap:
          name: grafana-dashboards
      - name: grafana-data
        persistentVolumeClaim:
          claimName: grafana-data
