operator-framework / operator-framework/operator-sdk

Dynamic namespace handling for ServiceMonitor serverName in operator metrics scraping

Open
#6,846 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

lifecycle/frozen
Dominant language
Go
Stars
7.7k
Forks
1.8k
PR merge metrics
No merged PRs in 30d

Description

Feature Request

Describe the problem you need a feature to resolve.

We have the /metrics endpoint for the operator, and we create a ServiceMonitor to scrape those metrics. However, the ServiceMonitor requires a CA and a serverName. The serverName field depends on the namespace where the operator is installed.

If the user installs the operator in a namespace different from the default one, the serverName field is incorrect. This leads to the certificate being invalid, and as a result, the ServiceMonitor cannot scrape the metrics.

For example:

 tlsConfig:
   ca: {}
   caFile: /etc/prometheus/configmaps/serving-certs-ca-bundle/service-ca.crt
   cert: {}
   serverName: my-operator-controller-manager-metrics-service.my-namespace.svc

The current solution is to create the ServiceMonitor from the operator at runtime, but this solution is not ideal because it introduces OpenShift-specific logic in upstream operators.

Describe the solution you'd like.

We want the operator-sdk to dynamically handle the serverName configuration for the ServiceMonitor based on the namespace where the operator is installed. This would ensure that the correct serverName is used, regardless of the installation namespace, making the certificate valid and allowing the ServiceMonitor to scrape the metrics properly.

Or any alternative solution that can help with this use case.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source file or test is identified in the issue. Start by tracing the operator's /metrics ServiceMonitor configuration and how the installed namespace reaches the serverName field. Done means installations in non-default namespaces use a matching serverName so the certificate validates and metrics scraping succeeds.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, prometheus
Domain
observability
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.