kind: Deployment
apiVersion: apps/v1
metadata:
  name: grafana
  labels:
    app: grafana
  annotations:
    app.openshift.io/connects-to: influxdb
spec:
  replicas: 1
  selector:
    matchLabels:
      app: grafana
  template:
    metadata:
      labels:
        app: grafana
    spec:
      containers:
        - name: grafana
          image: docker.io/grafana/grafana:7.1.5
          imagePullPolicy: IfNotPresent
          env:
            - name: GF_SECURITY_ADMIN_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: grafana
                  key: admin.password
            - name: DS_USERNAME
              valueFrom:
                secretKeyRef:
                  name: influxdb-secret
                  key: read.username
            - name: DS_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: influxdb-secret
                  key: read.password
            - name: DS_DATABASE
              valueFrom:
                configMapKeyRef:
                  name: influxdb-config
                  key: databaseName
          readinessProbe:
            httpGet:
              path: /
              port: 3000
            initialDelaySeconds: 15
            timeoutSeconds: 1
          livenessProbe:
            httpGet:
              path: /
              port: 3000
            initialDelaySeconds: 15
            timeoutSeconds: 1
          ports:
            - containerPort: 3000
              name: web
              protocol: TCP
          resources:
            limits:
              memory: 1Gi
          volumeMounts:
            - mountPath: /var/lib/grafana
              name: grafana-storage
            - mountPath: /etc/grafana/provisioning/datasources
              name: grafana-datasources
            - mountPath: /etc/grafana/provisioning/dashboards
              name: grafana-dashboard-providers
            - mountPath: /var/lib/grafana/dashboards
              name: grafana-dashboards
      volumes:
        - name: grafana-storage
          persistentVolumeClaim:
            claimName: grafana-pvc
        - name: grafana-datasources
          configMap:
            name: grafana-datasources
        - name: grafana-dashboard-providers
          configMap:
            name: grafana-dashboard-providers
        - name: grafana-dashboards
          configMap:
            name: grafana-dashboards
