Skip to content

Add monitoring controller for metrics - #1959

Open
mayleighnmyers wants to merge 27 commits into
istio-ecosystem:mainfrom
mayleighnmyers:feature/coo-monitoring-controller
Open

mayleighnmyers wants to merge 27 commits into
istio-ecosystem:mainfrom
mayleighnmyers:feature/coo-monitoring-controller

Conversation

@mayleighnmyers

@mayleighnmyers mayleighnmyers commented May 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements SEP8471: a monitoring controller that automatically creates Prometheus Operator ServiceMonitor and PodMonitor resources so Istio control-plane and sidecar metrics can be scraped without manual Prometheus ConfigMap edits.

Opt-in via annotation on the Istio CR:

apiVersion: sailoperator.io/v1
kind: Istio
metadata:
  name: default
  annotations:
    sailoperator.io/monitoring: enabled
spec:
  namespace: istio-system

Relates to: OSSM-15085

What type of PR is this?

  • [X ] Enhancement / New Feature
  • Bug Fix
  • Refactor
  • Optimization
  • Test
  • Documentation Update

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #

Related Issue/PR # OSSM-15085

Additional information:

@linux-foundation-easycla

linux-foundation-easycla Bot commented May 18, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

@istio-testing

Copy link
Copy Markdown
Collaborator

Hi @mayleighnmyers. Thanks for your PR.

I'm waiting for a istio-ecosystem or istio member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@nrfox

nrfox commented May 28, 2026

Copy link
Copy Markdown
Contributor

Hi @mayleighnmyers,

How would users control this if they wanted to opt in or out? What will the API be for this? You can either open an issue and we can discuss it there or better yet create a SEP for this. We need to discuss how this will integrate with the operator before we can move forward with this.

@mayleighnmyers

Copy link
Copy Markdown
Contributor Author

Hi @mayleighnmyers,

How would users control this if they wanted to opt in or out? What will the API be for this? You can either open an issue and we can discuss it there or better yet create a SEP for this. We need to discuss how this will integrate with the operator before we can move forward with this.

So this is still in progress. Good call for the opt in/out. Something we can consider is adding a field either in the Istio CR or the istioRevision CR to allow users to opt in since right now it is currently always enabled. Yuanlin and I will be talking about this more in some future meeting when we have all ducks in a row. :)

@mayleighnmyers mayleighnmyers changed the title Add monitoring controller for COO (Cluster Observability Operator) [WIP] Add monitoring controller for COO (Cluster Observability Operator) May 28, 2026
Comment thread enhancements/SEP3-observability-integration.md Outdated
Comment thread enhancements/SEP3-observability-integration.md Outdated
Comment thread enhancements/SEP3-observability-integration.md Outdated
@nrfox

nrfox commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

The implementation of this broadly looks fine but I think the API will need to be larger than a boolean and will require the sail operator to have additional permissions which may not be relevant for non-openshift users. With ZTunnel and IstioRevisionTag we have targetRef fields that reference the Istio resource. Maybe we could do something similar with this integration.

There could be a standalone Integration resource that has 1. an Istio ref 2. refs to metrics or tracing resources. Something like:

  apiVersion: integration.ossm/v1alpha1
  kind: Integration
  metadata:
    name: my-integration
    namespace: istio-system
  spec:
    istioRef:
      name: default
    metrics:
      type: ClusterObservability
      clusterObservability:
        monitoringStackRef:
          name: my-stack
          namespace: monitoring
    tracing:
      type: TempoStack
      tempoStackRef:
        name: my-tempo
        namespace: tracing

Here istioRef is a reference to an Istio resource, monitoringStackRef is a reference to a MonitoringStack, and tempoStackRef is a reference to a TempoStack. For each of these references the controller would lookup the relevant fields in the reference and configure the Istio accordingly. For example, the controller would use the monitoringStackRef to find the resource label for the PodMonitor/ServiceMonitor resources.

This could even be its own deployment with its own ServiceAccount so that the Sail Operator wouldn't need to be granted additional permissions. Since a lot of the integrations may be OSSM specific, it may even make more sense to only have this available in ossm/sail-operator. Not sure.

Server side apply can ensure that any updates that the integrations controller makes to the Istio resource do not conflict with user supplied values.

The implementation included here would largely stay the same. The main change would be in the API to manage these integrations.

@mayleighnmyers mayleighnmyers changed the title [WIP] Add monitoring controller for COO (Cluster Observability Operator) Add monitoring controller for metrics Jun 15, 2026
@mayleighnmyers
mayleighnmyers marked this pull request as ready for review June 15, 2026 17:38
@mayleighnmyers
mayleighnmyers requested a review from a team as a code owner June 15, 2026 17:38
@mayleighnmyers
mayleighnmyers force-pushed the feature/coo-monitoring-controller branch from 22566a7 to c43fabb Compare June 16, 2026 16:36
@mayleighnmyers
mayleighnmyers force-pushed the feature/coo-monitoring-controller branch from c43fabb to 21661f3 Compare June 16, 2026 16:48
@mayleighnmyers
mayleighnmyers force-pushed the feature/coo-monitoring-controller branch from 795caee to 3373e36 Compare June 16, 2026 19:22
@mayleighnmyers
mayleighnmyers force-pushed the feature/coo-monitoring-controller branch from 25aa652 to 3c63e82 Compare June 24, 2026 14:14
@mayleighnmyers

Copy link
Copy Markdown
Contributor Author

/test scorecard

mayleighnmyers and others added 25 commits September 9, 2026 11:20
Signed-off-by: Mayleigh Tjapkes <mamyers@redhat.com>
Signed-off-by: Mayleigh Tjapkes <mamyers@redhat.com>
Signed-off-by: Mayleigh Tjapkes <mamyers@redhat.com>
Signed-off-by: Yuanlin Xu <yuanlin.xu@redhat.com>
Signed-off-by: Mayleigh Tjapkes <mamyers@redhat.com>
Signed-off-by: Mayleigh Tjapkes <mamyers@redhat.com>
Signed-off-by: Yuanlin Xu <yuanlin.xu@redhat.com>
Signed-off-by: Yuanlin Xu <yuanlin.xu@redhat.com>
Signed-off-by: Mayleigh Tjapkes <mamyers@redhat.com>
The gencheck job runs make gen, which updates bundle manifests from
chart CRDs. The bundle copy of sailoperator.io_istios.yaml was missing
the new spec.monitoring schema added for the monitoring controller.

Signed-off-by: Mayleigh Tjapkes <mamyers@redhat.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Signed-off-by: Mayleigh Tjapkes <mamyers@redhat.com>
Signed-off-by: Mayleigh Tjapkes <mamyers@redhat.com>
Signed-off-by: Mayleigh Tjapkes <mamyers@redhat.com>
Signed-off-by: Mayleigh Tjapkes <mamyers@redhat.com>
Signed-off-by: Mayleigh Tjapkes <mamyers@redhat.com>
Signed-off-by: Mayleigh Tjapkes <mamyers@redhat.com>
Signed-off-by: Mayleigh Tjapkes <mamyers@redhat.com>
Signed-off-by: Mayleigh Tjapkes <mamyers@redhat.com>
Signed-off-by: Mayleigh Tjapkes <mamyers@redhat.com>
Signed-off-by: Mayleigh Tjapkes <mamyers@redhat.com>
Signed-off-by: Mayleigh Tjapkes <mamyers@redhat.com>
Signed-off-by: Mayleigh Tjapkes <mamyers@redhat.com>
Signed-off-by: Mayleigh Tjapkes <mamyers@redhat.com>
Signed-off-by: Mayleigh Tjapkes <mamyers@redhat.com>
Signed-off-by: Mayleigh Tjapkes <mamyers@redhat.com>
Signed-off-by: Mayleigh Tjapkes <mamyers@redhat.com>
@mayleighnmyers
mayleighnmyers force-pushed the feature/coo-monitoring-controller branch from 5d0d01c to 134238e Compare September 11, 2026 13:34
@mayleighnmyers

Copy link
Copy Markdown
Contributor Author

/retest

@nrfox nrfox left a comment

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.

A few minor comments otherwise LGTM

Comment on lines +302 to +312
if tt.expectSMRevision != "" {
sm := &monitoringv1.ServiceMonitor{}
sm.SetGroupVersionKind(monitoringv1.SchemeGroupVersion.WithKind("ServiceMonitor"))
err := cl.Get(ctx, types.NamespacedName{
Name: tt.expectSMRevision + serviceMonitorNameSuffix,
Namespace: istioNamespace,
}, sm)
g.Expect(err).ToNot(HaveOccurred())
g.Expect(sm.Name).To(Equal(tt.expectSMRevision + serviceMonitorNameSuffix))
expectMonitoringLabels(g, sm.Labels, serviceMonitorMonitoring)
}

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.

Seems like we need an else here to check the negative conditions where we don't expect the service monitor to exist?

Comment on lines +314 to +329
if tt.expectPMNamespace != "" {
pm := &monitoringv1.PodMonitor{}
pm.SetGroupVersionKind(monitoringv1.SchemeGroupVersion.WithKind("PodMonitor"))
err := cl.Get(ctx, types.NamespacedName{
Name: istioName + podMonitorNameSuffix,
Namespace: tt.expectPMNamespace,
}, pm)
g.Expect(err).ToNot(HaveOccurred())
g.Expect(pm.Name).To(Equal(istioName + podMonitorNameSuffix))
expectMonitoringLabels(g, pm.Labels, podMonitorMonitoring)
g.Expect(pm.OwnerReferences).To(HaveLen(1))
g.Expect(pm.OwnerReferences[0].Kind).To(Equal(v1.IstioKind))
g.Expect(pm.OwnerReferences[0].Name).To(Equal(istioName))
g.Expect(pm.OwnerReferences[0].Controller).ToNot(BeNil())
g.Expect(*pm.OwnerReferences[0].Controller).To(BeTrue())
}

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.

Same here.

{
ObjectMeta: revisionMeta,
Spec: v1.IstioRevisionSpec{
Version: "v1.24.0",

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.

Why is the version for Istio v1.29.2 and the version of the IstioRevision v1.24.0? It may not affect the tests but looks odd. You may not need to specify the version at all. It should get defaulted.

}
}

func TestReconcilePodMonitors(t *testing.T) {

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.

Are these tests duplicates of TestReconcile?

OwnerReferences: []metav1.OwnerReference{
{
APIVersion: v1.GroupVersion.String(),
Kind: v1.IstioRevisionKind,

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.

Shouldn't this be the Istio resource and not the IstioRevision similar to the PodMonitor?

Comment on lines +57 to +64
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts --force-update
helm repo update

# Admission webhooks require a certgen Job that talks to the webhook Service. On KinD
# that Job frequently times out (the webhook Service is not reachable until kube-proxy
# is healthy), which would also make helm --wait hang. The monitoring e2e only needs CRDs
# and scrape targets, so webhooks are disabled. --wait then tracks the operator Deployment.
helm install "${PROM_RELEASE}" prometheus-community/kube-prometheus-stack \

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.

Doing helm repo add and helm repo update will have side effects on the machine this hack script is run on. Can you install the helm chart using --repo and the url directly?

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.

We'll probably want to expose a util package for installing the integration dependencies and handling the differences between helm vs. OLM but just keep this as is for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants