fix prometheus

This commit is contained in:
2025-03-30 19:28:36 +02:00
parent 024a77e6cc
commit a3d3dd8336
5 changed files with 26 additions and 15 deletions

View File

@@ -114,13 +114,13 @@ spec:
httpGet:
path: /health/live
port: 9000 # Use management port for liveness
initialDelaySeconds: 90
initialDelaySeconds: 60
periodSeconds: 30
readinessProbe:
httpGet:
path: /health/ready
port: 9000 # Use management port for readiness
initialDelaySeconds: 60
initialDelaySeconds: 30
periodSeconds: 15
affinity:
# Spread pods across different nodes for higher availability

View File

@@ -9,7 +9,7 @@ local kp = (import 'kube-prometheus/main.libsonnet') + {
// Disable the built-in Grafana component
grafana+:: {},
// Prometheus customizations: external URL and persistent storage
// Prometheus customizations: external URL, persistent storage, and self-scrape enabled
prometheus+:: {
prometheus+: {
spec+: {
@@ -24,6 +24,22 @@ local kp = (import 'kube-prometheus/main.libsonnet') + {
},
},
},
// Enable self-scraping so Prometheus will automatically scrape its own /metrics endpoint
selfScrape: true,
// Set a ServiceMonitor selector that matches the Prometheus service's labels
serviceMonitorSelector: {
matchLabels: {
"k8s-app": "prometheus",
},
},
},
},
// Ensure the Prometheus service gets the label so that the selector above matches it
service+: {
metadata+: {
labels: {
"k8s-app": "prometheus",
},
},
},
},

View File

@@ -2,11 +2,7 @@ apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
labels:
app.kubernetes.io/component: prometheus
app.kubernetes.io/instance: k8s
app.kubernetes.io/name: prometheus
app.kubernetes.io/part-of: kube-prometheus
app.kubernetes.io/version: 3.2.1
k8s-app: prometheus
name: prometheus-k8s
namespace: monitoring
spec:

View File

@@ -46,9 +46,12 @@ spec:
fsGroup: 2000
runAsNonRoot: true
runAsUser: 1000
selfScrape: true
serviceAccountName: prometheus-k8s
serviceMonitorNamespaceSelector: {}
serviceMonitorSelector: {}
serviceMonitorSelector:
matchLabels:
k8s-app: prometheus
storage:
volumeClaimTemplate:
spec:

View File

@@ -2,11 +2,7 @@ apiVersion: v1
kind: Service
metadata:
labels:
app.kubernetes.io/component: prometheus
app.kubernetes.io/instance: k8s
app.kubernetes.io/name: prometheus
app.kubernetes.io/part-of: kube-prometheus
app.kubernetes.io/version: 3.2.1
k8s-app: prometheus
name: prometheus-k8s
namespace: monitoring
spec: