From fbf2deccd1a9fc3e497ec01ae437741ba57fa8af Mon Sep 17 00:00:00 2001 From: Priyank Upadhyay Date: Wed, 30 Oct 2024 11:31:19 +0530 Subject: [PATCH] fix(): configurable ns exclusion list (#408) * fix(): configurable ns exclusion list Signed-off-by: Priyank Upadhyay * fix(): refactors Signed-off-by: Priyank Upadhyay --------- Signed-off-by: Priyank Upadhyay --- pkg/namespace/controllers/reconciler.go | 7 +++++-- pkg/utils/constants.go | 5 +++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pkg/namespace/controllers/reconciler.go b/pkg/namespace/controllers/reconciler.go index b74596fd7..ddeeee205 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" @@ -49,8 +50,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" @@ -69,6 +69,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", utils.DefaultExcludedNS) + excludedNs = strings.Split(excludedNsEnv, ",") for _, v := range excludedNs { if v == req.Name { return ctrl.Result{}, nil diff --git a/pkg/utils/constants.go b/pkg/utils/constants.go index bca137326..678c78124 100644 --- a/pkg/utils/constants.go +++ b/pkg/utils/constants.go @@ -1,6 +1,7 @@ package utils const ( - NotApplicable = "NA" - EventsVersion = "v1alpha1" + NotApplicable = "NA" + EventsVersion = "v1alpha1" + DefaultExcludedNS = "kube-system,default,kubeslice-system,kube-node-lease,kube-public,istio-system" )