apiVersion: apps/v1
kind: Deployment
metadata:
  name: sep-backend-prometheus
  namespace: singouins-dev
  labels:
    tier: sep-backend
    app: prometheus-server
spec:
  replicas: 1
  selector:
    matchLabels:
      app: prometheus-server
  template:
    metadata:
      labels:
        tier: sep-backend
        app: prometheus-server
    spec:

      initContainers:
      - name: sep-backend-prometheus-data-permission-setup
        image: busybox
        command: ["/bin/chown","-R","65534:65534","/prometheus"]
        volumeMounts:
        - name: prometheus-storage-volume
          mountPath: /prometheus

      containers:
        - name: sep-backend-prometheus
          image: prom/prometheus:v2.32.0
          resources:
            limits:
              memory: 1024Mi
              cpu: 200m
            requests:
              memory: 256Mi
              cpu: 50m
          args:
            - "--config.file=/etc/prometheus/prometheus.yml"
            - "--storage.tsdb.path=/prometheus"
            - "--storage.tsdb.retention.size=80GB"
            - "--storage.tsdb.retention.time=90d"
          ports:
            - containerPort: 9090
          volumeMounts:
            - name: prometheus-config-volume
              mountPath: /etc/prometheus/
            - name: prometheus-storage-volume
              mountPath: /prometheus

      volumes:
        - name: prometheus-config-volume
          configMap:
            defaultMode: 420
            name: prometheus-server-conf

        - name: prometheus-storage-volume
          persistentVolumeClaim:
            claimName: sep-backend-prometheus
