chart(selenium-grid): add ServiceMonitor and PodMonitor support for Prometheus Operator#3121
Conversation
Add Prometheus Operator ServiceMonitor and PodMonitor resources for the metrics exporter, allowing users to integrate with kube-prometheus-stack without manually configuring additionalScrapeConfigs. - Name the exporter container port `metrics` for explicit port referencing - Keep service port name `http-port` (no breaking change); targetPort now references the named port `metrics` - Add `monitoring-service-monitor.yaml`: ServiceMonitor scraping via the exporter Service on port `http-port` - Add `monitoring-pod-monitor.yaml`: PodMonitor scraping pods directly on port `metrics` (alternative to ServiceMonitor) - Add `monitoring.serviceMonitor.*` and `monitoring.podMonitor.*` values (enabled, namespace, labels, annotations, path, interval, scrapeTimeout, relabelings, metricRelabelings); both disabled by default Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Review Summary by QodoAdd ServiceMonitor and PodMonitor support for Prometheus Operator
WalkthroughsDescription• Add Prometheus Operator ServiceMonitor and PodMonitor resources • Name exporter container port metrics for explicit referencing • Update Service targetPort to reference named port metrics • Add configurable monitoring values for both resource types Diagramflowchart LR
A["Exporter Deployment"] -->|named port metrics| B["Service"]
B -->|ServiceMonitor| C["Prometheus Operator"]
A -->|PodMonitor| C
D["values.yaml"] -->|serviceMonitor config| B
D -->|podMonitor config| A
File Changes1. charts/selenium-grid/templates/monitoring-exporter-deployment.yaml
|
Code Review by Qodo
1. Cross-namespace monitor fails
|
|
@DrFaust92, hopefully, this has been done with the end-to-end deployment and test in your local cluster, and confirmed it works as designed and expected. |
HI VietND96, weve been extending this chart with the service monitor resource in my company. this is upstreaming it with ability to save on the extra service as a podmonitor is sufficient here |
|
@DrFaust92, thank you, that's great! |
Motivation
Users running kube-prometheus-stack currently have no native way to scrape the Selenium Grid metrics exporter via Prometheus Operator. The only option is to configure
additionalScrapeConfigsmanually. This PR adds first-classServiceMonitorandPodMonitorsupport.Changes
metrics) on the exporter Deployment — explicit port referencing instead of a magic numbertargetPortupdated to reference the named portmetrics(port namehttp-portpreserved — no breaking change)monitoring-service-monitor.yaml— newServiceMonitorresource scraping the exporter Service on porthttp-portmonitoring-pod-monitor.yaml— newPodMonitorresource scraping exporter Pods directly on portmetrics(alternative for users without a Service)values.yaml— newmonitoring.serviceMonitor.*andmonitoring.podMonitor.*blocks; both disabled by defaultUsage
Testing
Both render valid
monitoring.coreos.com/v1resources with correct port references.