# services/monitoring/platform-quality-gateway-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: platform-quality-gateway
  namespace: monitoring
  labels:
    app: platform-quality-gateway
spec:
  replicas: 1
  revisionHistoryLimit: 3
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 0
      maxUnavailable: 1
  selector:
    matchLabels:
      app: platform-quality-gateway
  template:
    metadata:
      labels:
        app: platform-quality-gateway
    spec:
      securityContext:
        fsGroup: 65534
        fsGroupChangePolicy: OnRootMismatch
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
              - matchExpressions:
                  - key: kubernetes.io/hostname
                    operator: NotIn
                    values:
                      - titan-04
                      - titan-07
                      - titan-11
                      - titan-22
                      - titan-24
                  - key: hardware
                    operator: In
                    values:
                      - rpi5
                  - key: node-role.kubernetes.io/worker
                    operator: Exists
      containers:
        - name: pushgateway
          image: prom/pushgateway:v1.11.2
          securityContext:
            runAsGroup: 65534
            runAsNonRoot: true
            runAsUser: 65534
          args:
            - --web.listen-address=:9091
            - --web.enable-admin-api
            - --persistence.file=/data/metrics.db
            - --persistence.interval=1m
          ports:
            - name: http
              containerPort: 9091
          livenessProbe:
            httpGet:
              path: /-/healthy
              port: http
            initialDelaySeconds: 15
            timeoutSeconds: 5
            periodSeconds: 10
            failureThreshold: 6
          readinessProbe:
            httpGet:
              path: /-/ready
              port: http
            initialDelaySeconds: 5
            timeoutSeconds: 5
            periodSeconds: 5
            failureThreshold: 6
          resources:
            requests:
              cpu: 100m
              memory: 128Mi
            limits:
              cpu: 1
              memory: 1Gi
          volumeMounts:
            - name: data
              mountPath: /data
      volumes:
        - name: data
          persistentVolumeClaim:
            claimName: platform-quality-gateway-data
