From b7815acbabec2251056f80934cd0fb65f6b075ec Mon Sep 17 00:00:00 2001 From: Priyank Upadhyay Date: Tue, 29 Oct 2024 18:47:53 +0530 Subject: [PATCH 1/2] 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 From 357b4e88334f075b4cb00ed4131747131634605e Mon Sep 17 00:00:00 2001 From: Priyank Upadhyay Date: Tue, 29 Oct 2024 21:01:24 +0530 Subject: [PATCH 2/2] fix(): refactors Signed-off-by: Priyank Upadhyay --- pkg/namespace/controllers/reconciler.go | 2 +- pkg/utils/constants.go | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/namespace/controllers/reconciler.go b/pkg/namespace/controllers/reconciler.go index 2fd795a10..5e300a0b6 100644 --- a/pkg/namespace/controllers/reconciler.go +++ b/pkg/namespace/controllers/reconciler.go @@ -69,7 +69,7 @@ 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") + excludedNsEnv := utils.GetEnvOrDefault("EXCLUDED_NS", utils.DefaultExcludedNS) excludedNs = strings.Split(excludedNsEnv, ",") for _, v := range excludedNs { if v == req.Name { 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" )