apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: prometheus
    component: server
  name: prometheus-server
spec:
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app: prometheus
      component: server
  template:
    metadata:
      labels:
        app: prometheus
        component: server
    spec:
      containers:
        - args:
            - --storage.tsdb.retention.time=3d
            - --storage.tsdb.retention.size=1GB
            - --config.file=/etc/config/prometheus.yml
            - --storage.tsdb.path=/data
            - --web.console.libraries=/etc/prometheus/console_libraries
            - --web.console.templates=/etc/prometheus/consoles
            - --web.enable-lifecycle
          image: registry.homelab.dsb.dev/prom/prometheus:v2.24.0
          resources:
            limits:
              memory: 2Gi
              cpu: 500m
          livenessProbe:
            httpGet:
              path: /-/healthy
              port: 9090
            initialDelaySeconds: 30
            periodSeconds: 15
            timeoutSeconds: 30
          name: prometheus-server
          ports:
            - containerPort: 9090
              protocol: TCP
          readinessProbe:
            httpGet:
              path: /-/ready
              port: 9090
            initialDelaySeconds: 30
            periodSeconds: 5
            timeoutSeconds: 30
          volumeMounts:
            - mountPath: /etc/config
              name: config-volume
            - mountPath: /data
              name: storage-volume
      securityContext:
        fsGroup: 65534
        runAsGroup: 65534
        runAsNonRoot: true
        runAsUser: 65534
      serviceAccountName: prometheus-server
      terminationGracePeriodSeconds: 300
      volumes:
        - configMap:
            defaultMode: 420
            name: prometheus-server
          name: config-volume
        - name: storage-volume
          persistentVolumeClaim:
            claimName: prometheus-server
