patch-operator icon indicating copy to clipboard operation
patch-operator copied to clipboard

ServiceMonitor is created with invalid serverName value

Open X-dark opened this issue 3 years ago • 6 comments

Hi,

I have installed patch-operator version 0.1.4 through OperatorHub in a namespace named scale-patch-operator.

I can see that the serverName in the serviceMonitor is created with an invalid namespace name:

apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  resourceVersion: '57137052'
  name: patch-operator-controller-manager-metrics-monitor
[...]
  namespace: scale-patch-operator
  ownerReferences:
    - apiVersion: operators.coreos.com/v1alpha1
      blockOwnerDeletion: false
      controller: false
      kind: ClusterServiceVersion
      name: patch-operator.v0.1.4
      uid: 31655a3d-0f41-4612-a0a0-428236ffa20f
[...]
spec:
  endpoints:
    - bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
[...]
      tlsConfig:
        ca:
[...]
        serverName: patch-operator-controller-manager-metrics-service.patch-operator.svc
[...]

I would expect to see patch-operator-controller-manager-metrics-service.scale-patch-operator.svc there.

Looking at the code I do not understand the root cause as I see the value should come from METRICS_SERVICE_NAMESPACE variable: https://github.com/redhat-cop/patch-operator/blob/2766ff49f382fd81a53f557a1461bb28d410d642/config/prometheus/monitor.yaml#L22 which is initialized at metadata.namespace value: https://github.com/redhat-cop/patch-operator/blob/9ee4218d96ccc0e383eba7fc9a17fec7245712e8/config/default/kustomization.yaml#L59.

Or am I looking at the wrong location?

X-dark avatar Jul 20 '22 09:07 X-dark

if you are installing with OLM, you need to install in the recommended namespace or else you incur in this problem. This is an OLM problem and so far at least we have not found a solution to it.

On Wed, Jul 20, 2022 at 5:30 AM Cedric Girard @.***> wrote:

Hi,

I have installed patch-operator version 0.1.4 through OperatorHub in a namespace named scale-patch-operator.

I can see that the serverName in the serviceMonitor is created with an invalid namespace name:

apiVersion: monitoring.coreos.com/v1kind: ServiceMonitormetadata: resourceVersion: '57137052' name: patch-operator-controller-manager-metrics-monitor[...] namespace: scale-patch-operator ownerReferences: - apiVersion: operators.coreos.com/v1alpha1 blockOwnerDeletion: false controller: false kind: ClusterServiceVersion name: patch-operator.v0.1.4 uid: 31655a3d-0f41-4612-a0a0-428236ffa20f[...]spec: endpoints: - bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token[...] tlsConfig: ca:[...] serverName: patch-operator-controller-manager-metrics-service.patch-operator.svc[...]

I would expect to see patch-operator-controller-manager-metrics-service.scale-patch-operator.svc there.

Looking at the code I do not understand the root cause as I see the value should come from METRICS_SERVICE_NAMESPACE variable: https://github.com/redhat-cop/patch-operator/blob/2766ff49f382fd81a53f557a1461bb28d410d642/config/prometheus/monitor.yaml#L22 which is initialized at metadata.namespace value: https://github.com/redhat-cop/patch-operator/blob/9ee4218d96ccc0e383eba7fc9a17fec7245712e8/config/default/kustomization.yaml#L59 .

Or am I looking at the wrong location?

— Reply to this email directly, view it on GitHub https://github.com/redhat-cop/patch-operator/issues/33, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABPERXBDNAWVP45PIP4NWGLVU7BKVANCNFSM54C5KTOA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- ciao/bye Raffaele

raffaelespazzoli avatar Jul 20 '22 10:07 raffaelespazzoli

OK, understood. Is this already tracked in another issue?

X-dark avatar Jul 20 '22 12:07 X-dark

@davgordo where are we tracking this?

raffaelespazzoli avatar Jul 20 '22 13:07 raffaelespazzoli

@raffaelespazzoli any updates or workaround on this? What is the recommended namespace?

donflavour avatar Nov 09 '22 10:11 donflavour

the only namespace that works when installing via OLM is patch-operator. If you want to sue another namespace, you can use the helm chart.

raffaelespazzoli avatar Nov 09 '22 11:11 raffaelespazzoli

@davgordo where are we tracking this?

We discussed in depth and determined that the path forward would be to move the service monitor configuration out of the operator manifest and use the operator to create a service monitor instead. https://github.com/redhat-cop/operator-utils/issues/86

davgordo avatar Nov 14 '22 18:11 davgordo