apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: grafana
  namespace: ethereum-2
  labels:
    app.kubernetes.io/name: grafana
    app.kubernetes.io/version: "7.5.0"
spec:
  serviceName: grafana
  selector:
    matchLabels:
      app.kubernetes.io/name: grafana
  template:
    metadata:
      labels:
        app.kubernetes.io/name: grafana
        app.kubernetes.io/version: "7.5.0"
    spec:
      serviceAccountName: grafana
      containers:
      - name: grafana
        image: docker.io/grafana/grafana:7.5.0
        env:
        - name: GF_SERVER_PROTOCOL
          value: h2
        - name: GF_SERVER_CERT_KEY
          value: /etc/tls/tls.key
        - name: GF_SERVER_CERT_FILE
          value: /etc/tls/tls.crt
        ports:
        - name: http
          containerPort: 3000
        resources:
          requests:
            cpu: 50m
            memory: 50Mi
          limits:
            cpu: 100m
            memory: 100Mi
        volumeMounts:
        - mountPath: /etc/tls
          name: tls
          readOnly: true
        - mountPath: /var/lib/grafana
          name: data
        readinessProbe:
          httpGet:
            path: /api/health
            port: http
            scheme: HTTPS
          failureThreshold: 5
          initialDelaySeconds: 60
          periodSeconds: 10
          successThreshold: 1
          timeoutSeconds: 30
        livenessProbe:
          httpGet:
            path: /api/health
            port: http
            scheme: HTTPS
          failureThreshold: 5
          initialDelaySeconds: 600
          periodSeconds: 60
          successThreshold: 1
          timeoutSeconds: 30
        securityContext:
          runAsNonRoot: true
          runAsUser: 65534
          readOnlyRootFilesystem: true
          capabilities:
            drop: ["ALL"]
      securityContext:
        fsGroup: 65534
      terminationGracePeriodSeconds: 300
      volumes:
      - name: tls
        secret:
          secretName: grafana-tls
  volumeClaimTemplates:
  - metadata:
      name: data
    spec:
      storageClassName: standard-rwo
      accessModes:
      - ReadWriteOnce
      volumeMode: Filesystem
      resources:
        requests:
          storage: 1Gi
