apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    deployment.kubernetes.io/revision: "1"
  labels:
    app.kubernetes.io/name: postgres-operator-monitoring
  name: crunchy-grafana
spec:
  progressDeadlineSeconds: 600
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app.kubernetes.io/name: postgres-operator-monitoring
      name: crunchy-grafana
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      labels:
        app.kubernetes.io/name: postgres-operator-monitoring
        name: crunchy-grafana
    spec:
      containers:
      - env:
        - name: GF_PATHS_DATA
          value: /data/grafana/data
        - name: GF_SECURITY_ADMIN_USER__FILE
          value: /conf/admin/username
        - name: GF_SECURITY_ADMIN_PASSWORD__FILE
          value: /conf/admin/password
        - name: PROM_HOST
          value: crunchy-prometheus
        - name: PROM_PORT
          value: "9090"
        image: grafana/grafana:7.4.5
        imagePullPolicy: IfNotPresent
        livenessProbe:
          failureThreshold: 3
          httpGet:
            path: /api/health
            port: 3000
            scheme: HTTP
          initialDelaySeconds: 25
          periodSeconds: 20
          successThreshold: 1
          timeoutSeconds: 1
        name: grafana
        ports:
        - containerPort: 3000
          protocol: TCP
        readinessProbe:
          failureThreshold: 3
          httpGet:
            path: /api/health
            port: 3000
            scheme: HTTP
          periodSeconds: 10
          successThreshold: 1
          timeoutSeconds: 1
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
        volumeMounts:
        - mountPath: /data
          name: grafanadata
        - mountPath: /conf/admin
          name: grafana-secret
        - mountPath: /etc/grafana/provisioning/datasources
          name: grafana-datasources
        - mountPath: /etc/grafana/provisioning/dashboards
          name: grafana-dashboards
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      securityContext:
        fsGroup: 26
        # supplementalGroups : 65534
      schedulerName: default-scheduler
      serviceAccount: grafana
      serviceAccountName: grafana
      terminationGracePeriodSeconds: 30
      volumes:
      - name: grafanadata
        persistentVolumeClaim:
          claimName: grafanadata
      - name: grafana-secret
        secret:
          defaultMode: 420
          secretName: grafana-secret
      - configMap:
          defaultMode: 420
          name: grafana-datasources
        name: grafana-datasources
      - configMap:
          defaultMode: 420
          name: grafana-dashboards
        name: grafana-dashboards

