Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ spec:
{{- $imageRegistry := default .Values.global.seleniumGrid.imageRegistry .Values.monitoring.exporter.imageRegistry }}
image: {{ printf "%s/%s:%s" $imageRegistry .Values.monitoring.exporter.imageName .Values.monitoring.exporter.imageTag | quote }}
ports:
- containerPort: {{ .Values.monitoring.exporter.port }}
- name: metrics
containerPort: {{ .Values.monitoring.exporter.port }}
{{- with .Values.monitoring.exporter.tolerations }}
tolerations: {{ toYaml . | nindent 6 }}
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ spec:
- name: http-port
protocol: TCP
port: {{ .Values.monitoring.exporter.port }}
targetPort: {{ .Values.monitoring.exporter.port }}
targetPort: metrics
{{- if and (eq .Values.monitoring.exporter.service.type "NodePort") .Values.monitoring.exporter.service.nodePort }}
nodePort: {{ .Values.monitoring.exporter.service.nodePort }}
{{- end }}
Expand Down
33 changes: 33 additions & 0 deletions charts/selenium-grid/templates/monitoring-pod-monitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{{- if and (eq (include "seleniumGrid.monitoring.enabled" $) "true") .Values.monitoring.podMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
name: {{ template "seleniumGrid.monitoring.exporter.fullname" $ }}
namespace: {{ .Values.monitoring.podMonitor.namespace | default .Release.Namespace }}
{{- with .Values.monitoring.podMonitor.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "seleniumGrid.commonLabels" $ | nindent 4 }}
{{- with .Values.monitoring.podMonitor.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
selector:
matchLabels:
app.kubernetes.io/name: {{ template "seleniumGrid.monitoring.exporter.fullname" $ }}
podMetricsEndpoints:
- port: metrics
path: {{ .Values.monitoring.podMonitor.path }}
interval: {{ .Values.monitoring.podMonitor.interval }}
scrapeTimeout: {{ .Values.monitoring.podMonitor.scrapeTimeout }}
{{- with .Values.monitoring.podMonitor.relabelings }}
relabelings:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.monitoring.podMonitor.metricRelabelings }}
metricRelabelings:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
33 changes: 33 additions & 0 deletions charts/selenium-grid/templates/monitoring-service-monitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{{- if and (eq (include "seleniumGrid.monitoring.enabled" $) "true") .Values.monitoring.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ template "seleniumGrid.monitoring.exporter.fullname" $ }}
namespace: {{ .Values.monitoring.serviceMonitor.namespace | default .Release.Namespace }}
{{- with .Values.monitoring.serviceMonitor.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "seleniumGrid.commonLabels" $ | nindent 4 }}
{{- with .Values.monitoring.serviceMonitor.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
selector:
matchLabels:
app.kubernetes.io/name: {{ template "seleniumGrid.monitoring.exporter.fullname" $ }}
endpoints:
Comment on lines +5 to +20
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

1. Cross-namespace monitor fails 🐞 Bug ≡ Correctness

ServiceMonitor/PodMonitor can be deployed to a user-specified namespace, but the exporter
Service/Pods are always created in the release namespace. Because the monitors don't set any
namespace selector, moving them to another namespace prevents them from selecting the exporter
targets, so scraping won't happen.
Agent Prompt
### Issue description
`ServiceMonitor`/`PodMonitor` support `.Values.monitoring.{serviceMonitor,podMonitor}.namespace`, but the exporter Service/Pods always live in `.Release.Namespace`. Without a `spec.namespaceSelector`, deploying the monitor to a different namespace makes it unable to discover targets.

### Issue Context
The exporter resources are namespaced to `.Release.Namespace`, while the new monitor templates optionally change `metadata.namespace`.

### Fix Focus Areas
- charts/selenium-grid/templates/monitoring-service-monitor.yaml[5-33]
- charts/selenium-grid/templates/monitoring-pod-monitor.yaml[5-33]
- charts/selenium-grid/values.yaml[1044-1084]

### Expected fix
1. Add a configurable `namespaceSelector` block for both ServiceMonitor and PodMonitor (e.g., `monitoring.serviceMonitor.namespaceSelector` / `monitoring.podMonitor.namespaceSelector`).
2. Default it so targets are selected from `.Release.Namespace` (or allow empty `{}` to mean “same namespace” but document clearly).
3. If you keep the `namespace` override, ensure the default behavior (monitor in release namespace) still works unchanged.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

- port: http-port
path: {{ .Values.monitoring.serviceMonitor.path }}
interval: {{ .Values.monitoring.serviceMonitor.interval }}
scrapeTimeout: {{ .Values.monitoring.serviceMonitor.scrapeTimeout }}
{{- with .Values.monitoring.serviceMonitor.relabelings }}
relabelings:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.monitoring.serviceMonitor.metricRelabelings }}
metricRelabelings:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
40 changes: 40 additions & 0 deletions charts/selenium-grid/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1041,6 +1041,46 @@ monitoring:
key: ""
value: ""
annotations: {}
# -- ServiceMonitor configuration for Prometheus Operator
serviceMonitor:
# -- Enable ServiceMonitor resource
enabled: false
# -- Namespace to deploy the ServiceMonitor into (defaults to release namespace)
namespace: ""
# -- Additional labels for the ServiceMonitor
labels: {}
# -- Additional annotations for the ServiceMonitor
annotations: {}
# -- Metrics scrape path
path: /metrics
# -- Scrape interval
interval: 30s
# -- Scrape timeout
scrapeTimeout: 10s
# -- RelabelConfigs to apply to samples before scraping
relabelings: []
# -- MetricRelabelConfigs to apply to samples before ingestion
metricRelabelings: []
# -- PodMonitor configuration for Prometheus Operator (alternative to ServiceMonitor)
podMonitor:
# -- Enable PodMonitor resource
enabled: false
# -- Namespace to deploy the PodMonitor into (defaults to release namespace)
namespace: ""
# -- Additional labels for the PodMonitor
labels: {}
# -- Additional annotations for the PodMonitor
annotations: {}
# -- Metrics scrape path
path: /metrics
# -- Scrape interval
interval: 30s
# -- Scrape timeout
scrapeTimeout: 10s
# -- RelabelConfigs to apply to samples before scraping
relabelings: []
# -- MetricRelabelConfigs to apply to samples before ingestion
metricRelabelings: []

# Keda scaled object configuration
autoscaling:
Expand Down
Loading