Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always include operator namespace in cached k8s client namespaces #2566

Merged
merged 7 commits into from
Feb 14, 2020
13 changes: 7 additions & 6 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,15 +239,16 @@ func execute() {

// configure the manager cache based on the number of managed namespaces
managedNamespaces := viper.GetStringSlice(operator.NamespacesFlag)
switch len(managedNamespaces) {
case 0:
switch {
case len(managedNamespaces) == 0:
log.Info("Operator configured to manage all namespaces")
case 1:
log.Info("Operator configured to manage a single namespace", "namespace", managedNamespaces[0])
case len(managedNamespaces) == 1 && managedNamespaces[0] == operatorNamespace:
log.Info("Operator configured to manage a single namespace", "namespace", managedNamespaces[0], "operator_namespace", operatorNamespace)
opts.Namespace = managedNamespaces[0]
default:
log.Info("Operator configured to manage multiple namespaces", "namespaces", managedNamespaces)
opts.NewCache = cache.MultiNamespacedCacheBuilder(managedNamespaces)
log.Info("Operator configured to manage multiple namespaces", "namespaces", managedNamespaces, "operator_namespace", operatorNamespace)
// always include the operator namespace into the manager cache so that we can work with operator-internal resources in there
opts.NewCache = cache.MultiNamespacedCacheBuilder(append(managedNamespaces, operatorNamespace))
}

// only expose prometheus metrics if provided a non-zero port
Expand Down