---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: grafana
  name: grafana
  namespace: projectcontour-monitoring
spec:
  selector:
    matchLabels:
      app: grafana
  replicas: 1
  template:
    metadata:
      labels:
        app: grafana
    spec:
      containers:
        - name: grafana
          image: grafana/grafana:5.0.4
          imagePullPolicy: Always
          env:
            - name: GF_SECURITY_ADMIN_USER
              valueFrom:
                secretKeyRef:
                  name: grafana
                  key: grafana-admin-user
            - name: GF_SECURITY_ADMIN_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: grafana
                  key: grafana-admin-password
          ports:
            - containerPort: 3000
          readinessProbe:
            httpGet:
              path: /api/health
              port: 3000
            initialDelaySeconds: 30
            timeoutSeconds: 30
          resources:
            requests:
              cpu: 100m
              memory: 100Mi
          volumeMounts:
            - name: config-volume
              mountPath: /etc/grafana
            - name: dashboards-volume
              mountPath: /var/lib/grafana/dashboards
            - name: storage-volume
              mountPath: /var/lib/grafana
            - name: dashboard-provider
              mountPath: /etc/grafana/provisioning/dashboards
            - name: datasources-provider
              mountPath: /etc/grafana/provisioning/datasources
      terminationGracePeriodSeconds: 300
      volumes:
        - name: config-volume
          configMap:
            name: grafana-config
        - name: dashboards-volume
          configMap:
            name: grafana-dashs
        - name: storage-volume
          emptyDir: {}
        - name: dashboard-provider
          configMap:
            name: grafana-dash-provider
            items:
              - key: providers.yaml
                path: providers.yaml
        - name: datasources-provider
          configMap:
            name: grafana-datasources-provider
            items:
              - key: providers.yaml
                path: providers.yaml