diff --git a/internal/backend/kubernetes/backend.go b/internal/backend/kubernetes/backend.go index dca33eb1..6d6e5654 100644 --- a/internal/backend/kubernetes/backend.go +++ b/internal/backend/kubernetes/backend.go @@ -51,7 +51,9 @@ func NewBackend(ctx context.Context, cfg Config) (*Backend, error) { conf := func(opts *cluster.Options) { opts.Scheme = scheme - opts.Cache.DefaultNamespaces = map[string]cache.Config{cfg.Namespace: {}} + if cfg.Namespace != "" { + opts.Cache.DefaultNamespaces = map[string]cache.Config{cfg.Namespace: {}} + } } clstr, err := cluster.New(cfg.ClientConfig, conf) @@ -104,14 +106,6 @@ func loadConfig(cfg Config) (Config, error) { } cfg.ClientConfig = config - // In the event no namespace was provided for override, we need to fill it in with whatever - // namespace was loaded from the kubeconfig. - namespace, _, err := loader.Namespace() - if err != nil { - return Config{}, err - } - cfg.Namespace = namespace - return cfg, nil }