apiVersion: apps/v1
kind: Deployment
metadata:
  name: grafana
  namespace: prow-monitoring
  labels:
    app: grafana
spec:
  #keep replicas 1 unless we have a solution to
  #A. GLB BackendConfig with session affinity, or
  #B. SHARED session between replicas
  replicas: 1
  selector:
    matchLabels:
      app: grafana
  template:
    metadata:
      labels:
        app: grafana
    spec:
      containers:
      - name: grafana
        args:
        - -config=/etc/grafana/grafana.ini
        image: grafana/grafana:7.5.11
        env:
        - name: GF_SECURITY_ADMIN_USER
          value: admin
        - name: GF_SECURITY_ADMIN_PASSWORD
          valueFrom:
            secretKeyRef:
              name: grafana
              key: admin_password
        ports:
        - containerPort: 3000
          name: http
        readinessProbe:
          httpGet:
            path: /api/health
            port: 3000
        resources:
          requests:
            cpu: 100m
            memory: 100Mi
        volumeMounts:
        - mountPath: /var/lib/grafana
          name: grafana-storage
          readOnly: false
        - mountPath: /etc/grafana
          name: grafana-config
          readOnly: false
        - mountPath: /etc/grafana/provisioning/datasources
          name: grafana-datasources
          readOnly: false
        - mountPath: /etc/grafana/provisioning/dashboards
          name: grafana-dashboard-sources
          readOnly: false
        - mountPath: /grafana-dashboards
          name: grafana-dashboards
          readOnly: false
      serviceAccountName: grafana
      volumes:
      - name: grafana-storage
        emptyDir: {}
      - name: grafana-config
        configMap:
          name: grafana-config
      - name: grafana-datasources
        configMap:
          name: grafana-datasources
      - name: grafana-dashboard-sources
        configMap:
          name: grafana-dashboard-sources
      - name: grafana-dashboards
        configMap:
          name: grafana-dashboards
      - name: grafana-nginx
        configMap:
          name: grafana-nginx
