Skip to content

Commit

Permalink
Merge pull request #1676 from facchettos/exportKubeconfig
Browse files Browse the repository at this point in the history
now sets up the controller with the exportkubeconfig namespace if it is set
  • Loading branch information
FabianKramm committed Apr 15, 2024
2 parents 00ffbb5 + 9355873 commit 8c9d335
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions pkg/setup/controller_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,20 @@ 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{}
}

if len(defaultNamespaces) == 0 {
return cache.Options{DefaultNamespaces: nil}
}
return cache.Options{DefaultNamespaces: defaultNamespaces}
}

Expand Down

0 comments on commit 8c9d335

Please sign in to comment.