---
apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: monitoring
  name: grafana
spec:
  replicas: 1
  selector:
    matchLabels:
      app: grafana
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: grafana
    spec:
      containers:
      - name: grafana
        image: grafana/grafana:8.1.2
        imagePullPolicy: IfNotPresent
        volumeMounts:
        - name: dashboards
          mountPath: "/etc/grafana/provisioning/dashboards/dashboardproviders.yaml"
          subPath: dashboardproviders.yaml
        - name: datasources
          mountPath: "/etc/grafana/provisioning/datasources/datasources.yaml"
          subPath: datasources.yaml
        - name: kubernetes-dashboards
          mountPath: "/var/lib/grafana/dashboards/kubernetes/"
        ports:
        - name: grafana
          containerPort: 3000
          protocol: TCP
        env:
        - name: GF_SECURITY_ADMIN_USER
          valueFrom:
            secretKeyRef:
              name: grafana
              key: admin-user
        - name: GF_SECURITY_ADMIN_PASSWORD
          valueFrom:
            secretKeyRef:
              name: grafana
              key: admin-password
        livenessProbe:
          failureThreshold: 10
          httpGet:
            path: /api/health
            port: grafana
          initialDelaySeconds: 30
          timeoutSeconds: 15
        readinessProbe:
          httpGet:
            path: /api/health
            port: grafana
      volumes:
      - name: dashboards
        configMap:
          name: dashboards
      - name: datasources
        configMap:
          name: datasources
      - name: kubernetes-dashboards
        configMap:
          name: kubernetes-dashboards
