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" )