apiVersion: apps/v1
kind: Deployment
metadata:
  name: grafana
  labels:
    app: grafana
spec:
  replicas: 2
  selector:
    matchLabels:
      app: grafana
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 0
      maxSurge: 1
  template:
    metadata:
      labels:
        app: grafana
    spec:
      containers:
      - name: grafana
        image: grafana/grafana:8.5.3
        env:
        - name: GF_ALERTING_ENABLED
          value: "false"
        - name: GF_AUTH_ANONYMOUS_ENABLED
          value: "true"
        - name: GF_AUTH_ANONYMOUS_ORG_NAME
          value: Haneru Developers
        - name: GF_INSTALL_PLUGINS
          value: https://github.com/doitintl/bigquery-grafana/archive/2.0.2.zip;doit-bigquery-datasource
        - name: GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS
          value: doitintl-bigquery-datasource
        - name: GF_RENDERING_CALLBACK_URL
          value: http://grafana:3000/
        - name: GF_RENDERING_SERVER_URL
          value: http://grafana-image-renderer:8081/render
        - name: GF_SNAPSHOTS_EXTERNAL_ENABLED
          value: "false"
        - name: GF_UNIFIED_ALERTING_ENABLED
          value: "true"
        ports:
        - containerPort: 3000
        volumeMounts:
        - mountPath: /etc/grafana/provisioning/datasources
          readOnly: true
          name: grafana-datasources
        livenessProbe:
          httpGet:
            port: 3000
            path: /api/health
          initialDelaySeconds: 10
          periodSeconds: 5
        readinessProbe:
          httpGet:
            port: 3000
            path: /api/health
          initialDelaySeconds: 10
          periodSeconds: 5
      volumes:
        - name: grafana-datasources
          configMap:
            name: grafana-datasources
