operator-framework / operator-lifecycle-manager

A management framework for extending Kubernetes with Operators
https://olm.operatorframework.io
Apache License 2.0
1.72k stars 545 forks source link

ServiceMonitor serverName filed incorrectly set by OLM #2619

Open raffaelespazzoli opened 2 years ago

raffaelespazzoli commented 2 years ago

Bug Report

What did you do? When deploying a ServiceMonitor object the serverName field should be updated to reflect the namespace in which the operator in begin deployed.

What did you expect to see? so foir exmaple if this is the ServiceMonitor in the bundle:

apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  labels:
    operator: volume-expander-operator
  name: volume-expander-operator-controller-manager-metrics-monitor
spec:
  endpoints:
  - bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
    interval: 30s
    port: https
    scheme: https
    tlsConfig:
      caFile: /etc/prometheus/configmaps/serving-certs-ca-bundle/service-ca.crt
      serverName: volume-expander-operator-controller-manager-metrics.volume-expander-operator.svc
  selector:
    matchLabels:
      operator: volume-expander-operator

and the operator is being deployed to the aaabbb namespace then OLM should change this to be

apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: labels: operator: volume-expander-operator name: volume-expander-operator-controller-manager-metrics-monitor spec: endpoints:

What did you see instead? Under which circumstances? A clear and concise description of what you expected to happen (or insert a code snippet).

Environment

quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:4b14ffcea52f9eb5952546634cb26bfb1d523a4dd81382021c71673fed91efa2


kubectl version
Client Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.0", GitCommit:"cb303e613a121a29364f75cc67d3d580833a7479", GitTreeState:"archive", BuildDate:"2021-07-22T00:00:00Z", GoVersion:"go1.16.6", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.3+e790d7f", GitCommit:"3a0f2c90b43e6cffd07f57b5b78dd9f083e47ee2", GitTreeState:"clean", BuildDate:"2021-12-14T02:10:38Z", GoVersion:"go1.16.6", Compiler:"gc", Platform:"linux/amd64"}

* Kubernetes cluster kind: 
OCP 4.9

**Possible Solution**

OLM should scan and fix that field, or even better just support deploying via an helm chart and let the operator packager worry about these kinds of things.

**Additional context**
Add any other context about the problem here.
exdx commented 2 years ago

Hi @raffaelespazzoli, thank you for opening this issue. This issue has gone undetected because most operators leveraging the ServiceMonitor object in the bundle are installed in a specific predefined namespace and do not need to update the serverName field dynamically at install-time.

This definitely feels like a valid bug and is worth continuing to triage.