From 3c4e6516083ca02246495fc41f79cbd5de108a94 Mon Sep 17 00:00:00 2001 From: Coleen Iona Quadros Date: Wed, 31 Jul 2024 13:04:35 +0200 Subject: [PATCH] use diff addon namespace for each hub Signed-off-by: Coleen Iona Quadros --- .../controllers/placementrule/manifestwork.go | 1 + .../controllers/placementrule/namespace.go | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/operators/multiclusterobservability/controllers/placementrule/manifestwork.go b/operators/multiclusterobservability/controllers/placementrule/manifestwork.go index eb4ecadee6..3227dcf2ce 100644 --- a/operators/multiclusterobservability/controllers/placementrule/manifestwork.go +++ b/operators/multiclusterobservability/controllers/placementrule/manifestwork.go @@ -214,6 +214,7 @@ func generateGlobalManifestResources(c client.Client, mco *mcov1beta2.MultiClust works := []workv1.Manifest{} // inject the namespace + spokeNameSpace = getSpokeNameSpace(c) works = injectIntoWork(works, generateNamespace()) // inject the image pull secret diff --git a/operators/multiclusterobservability/controllers/placementrule/namespace.go b/operators/multiclusterobservability/controllers/placementrule/namespace.go index 8f2452096a..f0d7cf79e7 100644 --- a/operators/multiclusterobservability/controllers/placementrule/namespace.go +++ b/operators/multiclusterobservability/controllers/placementrule/namespace.go @@ -5,7 +5,10 @@ package placementrule import ( + "context" + "github.com/stolostron/multicluster-observability-operator/operators/endpointmetrics/pkg/openshift" "os" + client "sigs.k8s.io/controller-runtime/pkg/client" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -17,7 +20,14 @@ var ( spokeNameSpace = os.Getenv("SPOKE_NAMESPACE") ) +func getSpokeNameSpace(c client.Client) string { + clusterID, _ := openshift.GetClusterID(context.TODO(), c) + spokeNameSpace = spokeNameSpace + "-" + clusterID + return spokeNameSpace +} + func generateNamespace() *corev1.Namespace { + return &corev1.Namespace{ TypeMeta: metav1.TypeMeta{ APIVersion: corev1.SchemeGroupVersion.String(),