{{- if .Values.serviceMonitor.enabled }} {{/* Chart-native, values-gated. A hand-authored ServiceMonitor CR applied next to the release is banned: it drifts from the chart, survives a `helm uninstall`, and nothing owns it. The api is scraped through its Service. The worker and reconciler have no Service — they are scraped by pod, which is why their metrics port is named and their pods carry the component label. */}} apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: name: {{ include "svcforge.fullname" . }}-api labels: {{- include "svcforge.labels" . | nindent 4 }} spec: selector: matchLabels: {{- include "svcforge.selectorLabels" (dict "ctx" $ "component" "api") | nindent 6 }} endpoints: - port: http path: /metrics interval: {{ .Values.serviceMonitor.interval }} --- apiVersion: monitoring.coreos.com/v1 kind: PodMonitor metadata: name: {{ include "svcforge.fullname" . }}-workers labels: {{- include "svcforge.labels" . | nindent 4 }} spec: selector: matchExpressions: - key: app.kubernetes.io/component operator: In values: [worker, reconciler] - key: app.kubernetes.io/instance operator: In values: [{{ .Release.Name }}] podMetricsEndpoints: - port: metrics path: /metrics interval: {{ .Values.serviceMonitor.interval }} {{- end }}