apiVersion: apps/v1
kind: Deployment
metadata:
  name: tilt-local-metrics-grafana
  labels:
    app.kubernetes.io/name: grafana
    app.kubernetes.io/part-of: tilt-local-metrics
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: grafana
      app.kubernetes.io/part-of: tilt-local-metrics
  template:
    metadata:
      labels:
        app.kubernetes.io/name: grafana
        app.kubernetes.io/part-of: tilt-local-metrics
    spec:      
      volumes:
        - name: ini-vol
          configMap:
            name: tilt-grafana-config
            items:
            - key: grafana.ini
              path: grafana.ini
        - name: provision-dashboards-vol
          configMap:
            name: tilt-grafana-config
            items:
            - key: dashboards.yaml
              path: dashboards.yaml
        - name: provision-datasources-vol
          configMap:
            name: tilt-grafana-config
            items:
            - key: datasource-prometheus.yaml
              path: datasource-prometheus.yaml
        - name: dashboard-vol
          configMap:
            name: tilt-grafana-dashboards
                
      containers:
        - name: grafana
          image: grafana/grafana:7.3.3
          
          ports:
            - name: http
              containerPort: 3000
              protocol: TCP
              
          volumeMounts:
            - name: ini-vol
              mountPath: /etc/grafana/grafana.ini
              subPath: grafana.ini
            - name: provision-dashboards-vol
              mountPath: /etc/grafana/provisioning/dashboards/dashboards.yaml
              subPath: dashboards.yaml
            - name: provision-datasources-vol
              mountPath: /etc/grafana/provisioning/datasources/datasource-prometheus.yaml
              subPath: datasource-prometheus.yaml
            - name: dashboard-vol
              mountPath: /var/lib/grafana/dashboards
          
          readinessProbe:
            httpGet:
              port: 3000
            initialDelaySeconds: 5
            periodSeconds: 10
