feat: expose provider metrics in the Helm chart - #2848
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the ratify-gatekeeper-provider Helm chart to expose the provider’s Prometheus /metrics endpoint via pod annotations and an optional Prometheus Operator PodMonitor, and wires the configured metrics port into the provider container args.
Changes:
- Add new
metricsvalues (enabled,port,podMonitor.*) and document them in the chart README. - Add conditional Prometheus scrape annotations and a named
metricscontainer port to the provider Deployment. - Add an optional
PodMonitortemplate for Prometheus Operator-based scraping.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| deployments/ratify-gatekeeper-provider/values.yaml | Introduces default metrics configuration values (enabled/port/PodMonitor settings). |
| deployments/ratify-gatekeeper-provider/templates/deployment.yaml | Adds scrape annotations, passes --metrics-port, and conditionally exposes the metrics container port. |
| deployments/ratify-gatekeeper-provider/templates/podmonitor.yaml | Adds an optional Prometheus Operator PodMonitor for scraping /metrics. |
| deployments/ratify-gatekeeper-provider/README.md | Documents the new metrics-related chart values. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2848 +/- ##
==========================================
+ Coverage 76.58% 76.63% +0.05%
==========================================
Files 89 89
Lines 4095 4104 +9
==========================================
+ Hits 3136 3145 +9
Misses 812 812
Partials 147 147 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
f06bfb8 to
25e0d9e
Compare
|
CI fix: the e2e helm install was timing out because the chart passes |
25e0d9e to
96c0be0
Compare
The metrics package (OTel + Prometheus, ported from v1) was never wired into the gatekeeper provider: the exporter was never initialized and no request duration was recorded, so the provider emitted no metrics and served no /metrics endpoint. Initialize the Prometheus exporter on startup behind a new --metrics-port flag (default 8888, 0 disables) and record verification/mutation request durations in the verify/mutate handlers. Exporter init failures are logged but non-fatal. Signed-off-by: Charles Wu <yuewu2@microsoft.com>
Wire the provider Prometheus /metrics endpoint into the chart: pass --metrics-enabled and --metrics-port when metrics.enabled is set, add the metrics container port, and add prometheus.io pod scrape annotations for annotation-based scraping. Signed-off-by: Charles Wu <yuewu2@microsoft.com>
96c0be0 to
46cefd5
Compare
Description
Exposes the provider's Prometheus
/metricsendpoint through the Helm chart.Note
Stacked on #2847, which adds the
--enable-metrics/--metrics-portflags to the provider. This branch contains that commit, so review the chart commit here; please merge #2847 first and I'll rebase ontomainafterward.Change
--enable-metricsand--metrics-portto the provider whenmetrics.enabledis true (matching the v1 flag convention).metrics, default8888).prometheus.io/{scrape,port,path}pod annotations for annotation-based Prometheus scraping.metricsvalues:enabled(defaulttrue) andport(default8888), documented in the chart README.A Prometheus Operator
PodMonitorwas split out of this PR per review feedback and will follow separately.Testing
helm templateverified:metrics.enabled=true):--enable-metrics+--metrics-port=8888, themetricscontainer port, and the scrape annotations are rendered.metrics.enabled=false: none of the above are rendered.--set-string metrics.port=9999: the port still renders as an integer (| int).