Skip to content

Commit

Permalink
fix(): configurable ns exclusion list (#408)
Browse files Browse the repository at this point in the history
* fix(): configurable ns exclusion list

Signed-off-by: Priyank Upadhyay <[email protected]>

* fix(): refactors

Signed-off-by: Priyank Upadhyay <[email protected]>

---------

Signed-off-by: Priyank Upadhyay <[email protected]>
  • Loading branch information
priyank-upadhyay authored and gourishkb committed Nov 18, 2024
1 parent 247409d commit fbf2dec
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
7 changes: 5 additions & 2 deletions pkg/namespace/controllers/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package namespace

import (
"context"
"strings"

"github.com/go-logr/logr"
"github.com/kubeslice/kubeslice-monitoring/pkg/events"
Expand Down Expand Up @@ -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"

Expand All @@ -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
Expand Down
5 changes: 3 additions & 2 deletions pkg/utils/constants.go
Original file line number Diff line number Diff line change
@@ -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"
)

0 comments on commit fbf2dec

Please sign in to comment.