From b7815acbabec2251056f80934cd0fb65f6b075ec Mon Sep 17 00:00:00 2001 From: Priyank Upadhyay Date: Tue, 29 Oct 2024 18:47:53 +0530 Subject: [PATCH] fix(): configurable ns exclusion list Signed-off-by: Priyank Upadhyay --- pkg/namespace/controllers/reconciler.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/namespace/controllers/reconciler.go b/pkg/namespace/controllers/reconciler.go index a234663da..2fd795a10 100644 --- a/pkg/namespace/controllers/reconciler.go +++ b/pkg/namespace/controllers/reconciler.go @@ -19,6 +19,7 @@ package namespace import ( "context" + "strings" "github.com/go-logr/logr" "github.com/kubeslice/kubeslice-monitoring/pkg/events" @@ -48,8 +49,7 @@ type Reconciler struct { Hubclient *hub.HubClientConfig } -var excludedNs = []string{"kube-system", "default", "kubeslice-system", "kube-node-lease", - "kube-public", "istio-system"} +var excludedNs []string var controllerName string = "namespaceReconciler" @@ -68,6 +68,9 @@ func (c *Reconciler) getSliceNameFromNs(ns string) (string, error) { } func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { + + excludedNsEnv := utils.GetEnvOrDefault("EXCLUDED_NS", "kube-system,default,kubeslice-system,kube-node-lease,kube-public,istio-system") + excludedNs = strings.Split(excludedNsEnv, ",") for _, v := range excludedNs { if v == req.Name { return ctrl.Result{}, nil