1# ============================================================================= 2# Prometheus (TASK-0135, phase-15) — Deployment + PVC + Service, ns `monitoring`. 3# 4# Config is generated into `prometheus-config` by kustomization.yaml FROM 5# infrastructure/observability/prometheus/ (single source of truth): 6# /etc/prometheus/prometheus.yml (scrape + rule_files + alerting) 7# /etc/prometheus/rules/recording-rules.yaml 8# /etc/prometheus/rules/alerts.yaml 9# Retention 7 d (the 14-day cert alert needs >14 d of history for its 10# avg_over_time-free expr, but 7 d is the staging default — bump if the 11# dashboards' 30 d views matter). 12# Image pinned: prom/prometheus:v2.51.0 (the 2.51 LTS line — classic text 13# format + the rule files above are 2.x syntax). 14# ============================================================================= 15apiVersion: v1 16kind: PersistentVolumeClaim 17metadata: 18 name: prometheus-data 19 namespace: monitoring 20 labels: 21 app.kubernetes.io/name: prometheus 22 app.kubernetes.io/part-of: ai-software-factory 23spec: 24 accessModes: ["ReadWriteOnce"] 25 resources: 26 requests: 27 storage: 10Gi 28--- 29apiVersion: apps/v1 30kind: Deployment 31metadata: 32 name: prometheus 33 namespace: monitoring 34 labels: 35 app.kubernetes.io/name: prometheus 36 app.kubernetes.io/part-of: ai-software-factory 37spec: 38 replicas: 1 39 selector: 40 matchLabels: 41 app.kubernetes.io/name: prometheus 42 strategy: 43 type: Recreate 44 template: 45 metadata: 46 labels: 47 app.kubernetes.io/name: prometheus 48 spec: 49 securityContext: 50 runAsNonRoot: true 51 runAsUser: 65534 # the `prom` user in the official image 52 runAsGroup: 65534 53 fsGroup: 65534 54 containers: 55 - name: prometheus 56 image: prom/prometheus:v2.51.0 57 imagePullPolicy: IfNotPresent 58 args: 59 - --config.file=/etc/prometheus/prometheus.yml 60 - --storage.tsdb.path=/prometheus 61 - --storage.tsdb.retention.time=7d 62 - --web.enable-lifecycle 63 ports: 64 - containerPort: 9090 65 name: http 66 volumeMounts: 67 - name: config 68 mountPath: /etc/prometheus 69 readOnly: true 70 - name: data 71 mountPath: /prometheus 72 readinessProbe: 73 httpGet: 74 path: /-/ready 75 port: 9090 76 initialDelaySeconds: 10 77 periodSeconds: 10 78 livenessProbe: 79 httpGet: 80 path: /-/healthy 81 port: 9090 82 initialDelaySeconds: 30 83 periodSeconds: 15 84 resources: 85 requests: 86 cpu: 250m 87 memory: 512Mi 88 limits: 89 cpu: "1" 90 memory: 2Gi 91 volumes: 92 - name: config 93 configMap: 94 name: prometheus-config # name rewritten to the hashed name by kustomize 95 - name: data 96 persistentVolumeClaim: 97 claimName: prometheus-data 98--- 99apiVersion: v1 100kind: Service 101metadata: 102 name: prometheus 103 namespace: monitoring 104 labels: 105 app.kubernetes.io/name: prometheus 106 app.kubernetes.io/part-of: ai-software-factory 107spec: 108 selector: 109 app.kubernetes.io/name: prometheus 110 ports: 111 - name: http 112 port: 9090 113 targetPort: 9090 114