From 5798259e980565a6d284ebb5809024b747c8174f Mon Sep 17 00:00:00 2001 From: facchettos Date: Fri, 12 Apr 2024 14:15:23 +0200 Subject: [PATCH 1/3] now sets up the controller with the exportkubeconfig namespace if it is set --- pkg/setup/controller_context.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pkg/setup/controller_context.go b/pkg/setup/controller_context.go index 3e2f13d93..cf7c11549 100644 --- a/pkg/setup/controller_context.go +++ b/pkg/setup/controller_context.go @@ -103,9 +103,15 @@ func NewControllerContext(ctx context.Context, options *config.VirtualClusterCon func getLocalCacheOptions(options *config.VirtualClusterConfig) cache.Options { // is multi namespace mode? - var defaultNamespaces map[string]cache.Config + defaultNamespaces := make(map[string]cache.Config) if !options.Experimental.MultiNamespaceMode.Enabled { - defaultNamespaces = map[string]cache.Config{options.WorkloadTargetNamespace: {}} + defaultNamespaces[options.WorkloadTargetNamespace] = cache.Config{} + } + // do we need access to another namespace to export the kubeconfig ? + // we will need access to all the objects that the vcluster usually has access to + // otherwise the controller will not start + if options.ExportKubeConfig.Secret.Namespace != "" { + defaultNamespaces[options.ExportKubeConfig.Secret.Namespace] = cache.Config{} } return cache.Options{DefaultNamespaces: defaultNamespaces} From 5188029ccbbbb84ac35f4a69f355ee0c64c95c6c Mon Sep 17 00:00:00 2001 From: facchettos Date: Fri, 12 Apr 2024 14:22:46 +0200 Subject: [PATCH 2/3] exact same behavior than before --- pkg/setup/controller_context.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/setup/controller_context.go b/pkg/setup/controller_context.go index cf7c11549..7ba8c3557 100644 --- a/pkg/setup/controller_context.go +++ b/pkg/setup/controller_context.go @@ -114,6 +114,9 @@ func getLocalCacheOptions(options *config.VirtualClusterConfig) cache.Options { defaultNamespaces[options.ExportKubeConfig.Secret.Namespace] = cache.Config{} } + if len(defaultNamespaces) > 0 { + return cache.Options{DefaultNamespaces: nil} + } return cache.Options{DefaultNamespaces: defaultNamespaces} } From 9355873e7232ecec71c11415af738d18e2141614 Mon Sep 17 00:00:00 2001 From: facchettos Date: Fri, 12 Apr 2024 14:50:33 +0200 Subject: [PATCH 3/3] fixed condition --- pkg/setup/controller_context.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/setup/controller_context.go b/pkg/setup/controller_context.go index 7ba8c3557..49f8320c2 100644 --- a/pkg/setup/controller_context.go +++ b/pkg/setup/controller_context.go @@ -114,7 +114,7 @@ func getLocalCacheOptions(options *config.VirtualClusterConfig) cache.Options { defaultNamespaces[options.ExportKubeConfig.Secret.Namespace] = cache.Config{} } - if len(defaultNamespaces) > 0 { + if len(defaultNamespaces) == 0 { return cache.Options{DefaultNamespaces: nil} } return cache.Options{DefaultNamespaces: defaultNamespaces}