From 4f9935c304225584616637eae02c525a9c1de017 Mon Sep 17 00:00:00 2001 From: Nicolas Bigler Date: Thu, 12 Dec 2024 10:49:08 +0100 Subject: [PATCH] Switch instances monitoring from cluster to user-workload monitoring Signed-off-by: Nicolas Bigler --- pkg/comp-functions/functions/common/billing.go | 9 +++++++++ .../functions/common/instance_namespace.go | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/pkg/comp-functions/functions/common/billing.go b/pkg/comp-functions/functions/common/billing.go index 5a76646340..7863deec06 100644 --- a/pkg/comp-functions/functions/common/billing.go +++ b/pkg/comp-functions/functions/common/billing.go @@ -4,9 +4,11 @@ import ( "context" _ "embed" "fmt" + xfnproto "github.com/crossplane/function-sdk-go/proto/v1beta1" v1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" "github.com/vshn/appcat/v4/pkg/comp-functions/runtime" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" controllerruntime "sigs.k8s.io/controller-runtime" ) @@ -75,6 +77,13 @@ func CreateBillingRecord(ctx context.Context, svc *runtime.ServiceRuntime, comp } p := &v1.PrometheusRule{ + ObjectMeta: metav1.ObjectMeta{ + Labels: map[string]string{ + // This label is required, the ensure that the rule is added to Prometheus and + // not the Thanos Rules in the Openshift User Workload Monitoring + "openshift.io/prometheus-rule-evaluation-scope": "leaf-prometheus", + }, + }, Spec: v1.PrometheusRuleSpec{ Groups: []v1.RuleGroup{ rg, diff --git a/pkg/comp-functions/functions/common/instance_namespace.go b/pkg/comp-functions/functions/common/instance_namespace.go index 0e6efd9e4e..9c3c12ae39 100644 --- a/pkg/comp-functions/functions/common/instance_namespace.go +++ b/pkg/comp-functions/functions/common/instance_namespace.go @@ -121,7 +121,7 @@ func createInstanceNamespace(serviceName, compName, claimNamespace, instanceName "appuio.io/no-rbac-creation": "true", "appuio.io/billing-name": billingName, "appuio.io/organization": org, - "openshift.io/cluster-monitoring": "true", + "openshift.io/cluster-monitoring": "false", }, }, }