apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: meta-grafana
  name: meta-grafana
  namespace: meta-monitoring
spec:
  replicas: 1
  selector:
    matchLabels:
      app: meta-grafana
  template:
    metadata:
      labels:
        app: meta-grafana
        layer: meta-monitoring
    spec:
      securityContext:
        fsGroup: 472
        supplementalGroups:
        - 0    
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: layer
                operator: In
                values:
                - meta-monitoring
      containers:
        - name: meta-grafana
          image: grafana/grafana:8.1.0
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 3000
              name: http-grafana
              protocol: TCP
          readinessProbe:
            failureThreshold: 3
            httpGet:
              path: /robots.txt
              port: 3000
              scheme: HTTP
            initialDelaySeconds: 10
            periodSeconds: 30
            successThreshold: 1
            timeoutSeconds: 2
          livenessProbe:
            failureThreshold: 3
            initialDelaySeconds: 30
            periodSeconds: 10
            successThreshold: 1
            tcpSocket:
              port: 3000
            timeoutSeconds: 1            
          resources:
            requests:
              cpu: 250m
              memory: 750Mi
          volumeMounts:
            - mountPath: /var/lib/grafana
              name: meta-grafana-pv
            - mountPath: /etc/grafana/provisioning/datasources
              name: config-datasources
              readOnly: false
            - mountPath: /etc/grafana/provisioning/dashboards
              name: config-dashboards
              readOnly: false
      volumes:
        - name: meta-grafana-pv
          persistentVolumeClaim:
            claimName: meta-grafana-pvc
        - name: config-datasources
          configMap:
            name: meta-grafana-datasources
        - name: config-dashboards
          configMap:
            defaultMode: 420
            name: meta-grafana-dashboards