chart: add backend ServiceMonitor (token-auth /metrics, off by default)
- /metrics is bearer-protected via METRICS_TOKEN; the endpoint carries authorization.credentials (pargar-app/metrics-token) so Prometheus scrapes it the same way the live probe does. - disabled by default: plain 'helm template' renders byte-identical; values-apollo enables it (enabled: true, interval 30s already present). - kube-prometheus (ns infra) selects ServiceMonitors in all namespaces; its operator holds cluster-wide secret read to resolve the credential.
This commit is contained in:
@@ -0,0 +1,29 @@
|
|||||||
|
{{- if .Values.backend.metrics.serviceMonitor.enabled }}
|
||||||
|
apiVersion: monitoring.coreos.com/v1
|
||||||
|
kind: ServiceMonitor
|
||||||
|
metadata:
|
||||||
|
name: {{ include "pargar.fullname" . }}-backend
|
||||||
|
labels:
|
||||||
|
{{- include "pargar.labels" . | nindent 4 }}
|
||||||
|
app.kubernetes.io/component: backend
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
{{- include "pargar.selectorLabels" . | nindent 6 }}
|
||||||
|
app.kubernetes.io/component: backend
|
||||||
|
namespaceSelector:
|
||||||
|
matchNames:
|
||||||
|
- {{ .Release.Namespace }}
|
||||||
|
endpoints:
|
||||||
|
- port: http
|
||||||
|
path: /metrics
|
||||||
|
interval: {{ .Values.backend.metrics.serviceMonitor.interval | default "30s" }}
|
||||||
|
scheme: http
|
||||||
|
# /metrics answers 401 without it; Prometheus sends it as
|
||||||
|
# Authorization: Bearer <token>.
|
||||||
|
authorization:
|
||||||
|
type: Bearer
|
||||||
|
credentials:
|
||||||
|
name: {{ include "pargar.appSecretName" . }}
|
||||||
|
key: metrics-token
|
||||||
|
{{- end }}
|
||||||
@@ -25,6 +25,13 @@ backend:
|
|||||||
pullPolicy: IfNotPresent
|
pullPolicy: IfNotPresent
|
||||||
service:
|
service:
|
||||||
port: 8080
|
port: 8080
|
||||||
|
metrics:
|
||||||
|
# Prometheus Operator ServiceMonitor. /metrics is bearer-protected by
|
||||||
|
# METRICS_TOKEN, so the endpoint carries authorization credentials
|
||||||
|
# (pargar-app secret) instead of scraping anonymously.
|
||||||
|
serviceMonitor:
|
||||||
|
enabled: false
|
||||||
|
interval: 30s
|
||||||
resources:
|
resources:
|
||||||
requests:
|
requests:
|
||||||
cpu: 50m
|
cpu: 50m
|
||||||
|
|||||||
Reference in New Issue
Block a user