apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: tfm-grafana
  name: tfm-grafana
spec:
  replicas: 1
  selector:
    matchLabels:
      app: tfm-grafana
  template:
    metadata:
      labels:
        app: tfm-grafana
    spec:
      containers:
        - name: grafana
          image: grafana/grafana:5.2.4          
          env:
            - name: GF_AUTH_BASIC_ENABLED
              value: "true"
            - name: GF_SECURITY_ADMIN_USER
              valueFrom:
                secretKeyRef:
                  name: tfm-grafana-credentials
                  key: grafana-admin-username
            - name: GF_SECURITY_ADMIN_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: tfm-grafana-credentials
                  key: grafana-admin-password
            - name: GF_AUTH_ANONYMOUS_ENABLED
              value: "false"
          ports:
            - containerPort: 3000
          resources:
            limits: 
              cpu: 500m
              memory: 512Mi
            requests:
              cpu: 100m
              memory: 512Mi
          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: tfm-grafana-config
        - name: dashboards-volume
          configMap:
            name: tfm-grafana-dashs
        - name: storage-volume
          emptyDir: {}
        - name: dashboard-provider
          configMap:
            name: tfm-grafana-dash-provider
        - name: datasources-provider
          configMap:
            name: tfm-grafana-datasources-provider