HYPERFLEET-581 - feat: Add ServiceMonitor to Helm chart for Prometheus Operator#43
Conversation
…s Operator Add ServiceMonitor template to enable automatic Prometheus Operator scraping of metrics on port 9090. Configuration options in values.yaml: - serviceMonitor.enabled (default: false) - serviceMonitor.interval (default: 30s) - serviceMonitor.scrapeTimeout (default: 10s) - serviceMonitor.labels (for Prometheus selector matching) - serviceMonitor.namespace (optional override)
WalkthroughThe pull request adds Prometheus Operator integration to the Helm chart by introducing a ServiceMonitor template (rendered when .Values.serviceMonitor.enabled is true), updates values.yaml with a serviceMonitor configuration block (enabled, interval, scrapeTimeout, labels, namespace), and extends documentation with a "Prometheus Operator Integration" section showing installation and configuration examples. The ServiceMonitor template sets apiVersion, kind, metadata, selector.matchLabels, optional namespace/namespaceSelector, and endpoints (port, path, interval, scrapeTimeout) based on chart values. Sequence Diagram(s)sequenceDiagram
participant Dev as Developer (Helm)
participant Helm as Helm CLI
participant K8s as Kubernetes API
participant PO as Prometheus Operator
participant Svc as Target Service
Dev->>Helm: helm install/upgrade chart (serviceMonitor.enabled=true)
Helm->>Helm: Render templates (ServiceMonitor created)
Helm->>K8s: Apply ServiceMonitor manifest
K8s->>PO: Persist ServiceMonitor resource
PO->>K8s: Discover ServiceMonitor.selector -> find matching Service
PO->>Svc: Scrape /metrics on configured port/path/interval
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Important Action Needed: IP Allowlist UpdateIf your organization protects your Git platform with IP whitelisting, please add the new CodeRabbit IP address to your allowlist:
Failure to add the new IP will result in interrupted reviews. Comment |
Add ServiceMonitor options to Helm values table and expand Monitoring section with usage examples.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@charts/templates/servicemonitor.yaml`:
- Line 1: Exclude Helm chart templates from yamllint by updating your CI
yamllint configuration to ignore the charts/templates directory (so directives
like "{{- if .Values.serviceMonitor.enabled }}" won't be parsed by yamllint),
and while editing charts/templates/servicemonitor.yaml also fix the brace
spacing complaint by normalizing template tag whitespace (e.g. remove extra
spaces inside mustache tags so occurrences of "{{ .Values.xxx }}" become
"{{.Values.xxx}}" or follow your project's template whitespace convention), then
run yamllint to confirm no remaining errors.
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: rh-amarin The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
3bd89c3
into
openshift-hyperfleet:main
Summary
ServiceMonitortemplate to enable automatic Prometheus Operator scraping of metricsserviceMonitorconfiguration section invalues.yamlwith configurable options:enabledflag (default: false)intervalsetting (default: 30s)scrapeTimeoutsetting (default: 10s)labelsfor Prometheus selector matchingnamespaceoverride optionTest plan
serviceMonitor.enabled=trueResolves: https://issues.redhat.com/browse/HYPERFLEET-581
Summary by CodeRabbit