apiVersion: apps/v1 kind: Deployment metadata: name: prometheus namespace: monitoring labels: app: prometheus spec: replicas: 1 selector: matchLabels: app: prometheus template: metadata: labels: app: prometheus annotations: prometheus.io/scrape: "true" prometheus.io/port: "9090" spec: serviceAccountName: prometheus securityContext: fsGroup: 65534 runAsNonRoot: true runAsUser: 65534 containers: - name: prometheus image: prom/prometheus:v2.48.0 args: - "--config.file=/etc/prometheus/prometheus.yml" - "--storage.tsdb.path=/prometheus" - "--storage.tsdb.retention.time=15d" - "--web.listen-address=0.0.0.0:9090" - "--web.enable-lifecycle" - "--web.enable-admin-api" ports: - name: http containerPort: 9090 protocol: TCP resources: requests: memory: "512Mi" cpu: "200m" limits: memory: "1Gi" cpu: "500m" volumeMounts: - name: config mountPath: /etc/prometheus - name: storage mountPath: /prometheus livenessProbe: httpGet: path: /-/healthy port: http initialDelaySeconds: 30 periodSeconds: 15 readinessProbe: httpGet: path: /-/ready port: http initialDelaySeconds: 5 periodSeconds: 5 volumes: - name: config configMap: name: prometheus-config - name: storage emptyDir: {} # For production, replace emptyDir with PVC: # - name: storage # persistentVolumeClaim: # claimName: prometheus-storage