Skip to content

Support for scrapeclass in VMServiceScrape, VMPodScrape, VMProbe #1531

@ankitdh7

Description

@ankitdh7

Use-case

We use prometheus ServiceMonitor, PodMonitor, and Probe as inputs for scraping targets. These resources are translated by the VM operator into VMServiceScrape, VMPodScrape, and VMProbe, which are then scraped by VMagent.

Recently, the Prometheus Operator introduced scrapeClass to standardize common configurations such as relabeling rules, TLS certificates, and authentication. This feature enables strict mTLS support in PodMonitors and Probes (ServiceMonitor already supported it via tlsConfig) for scraping workloads inside an Istio mesh.

While VMPodScrape already supports mTLS through tlsConfig, the issue arises when scraping config comes from ServiceMonitor, PodMonitor, and Probe. When these CRs are converted into their VM equivalents, the TLS settings from scrapeClass are not passed through, leaving us unable to use mTLS with VMPodScrape and VMProbe.

Steps to reproduce

  • Enable the scrapeclass in prometheus helm chart like this
  • Apply the podmonitor as below
kubectl apply -f - <<EOF
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
 name: test-podmonitor
 labels:
   release: prometheus 
spec:
 scrapeClass: istio-mtls
 podMetricsEndpoints:
 - interval: 60s
   path: /metrics
   port: metrics-port
   relabelings:
   - action: replace
     sourceLabels: [__meta_kubernetes_pod_label_status]
     targetLabel: status
   - action: replace
     sourceLabels: [pod]
     targetLabel: instance
 selector:
   matchLabels:
     app.kubernetes.io/instance: test
EOF
  • The pod monitor has been loaded with TLS config in prometheus
  • The translated VMPodscrape has been loaded in the VMagent but without TLS config

VM Versions:

  • Helm chart - victoria-metrics-k8s-stack-0.27.6
  • VMOperator - v0.48.3
  • VMAgent - v1.105.0
  • App version - v1.105.0

Could you please help if there are plans to support scrapeClass in the VM operator? If not, do you have any recommendations on how to achieve strict mTLS support for VMPodScrape and VMProbe when using ServiceMonitor, PodMonitor, and Probe as inputs? Thanks in advance!

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions