Skip to content

Commit

Permalink
Use cluster-scoped cache only when required (#3868) (#3871)
Browse files Browse the repository at this point in the history
  • Loading branch information
charith-elastic committed Oct 22, 2020
1 parent 4e2ee87 commit b7df6f4
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,9 +459,15 @@ func startOperator(stopChan <-chan struct{}) error {
opts.Namespace = managedNamespaces[0]
default:
log.Info("Operator configured to manage multiple namespaces", "namespaces", managedNamespaces, "operator_namespace", operatorNamespace)
// the manager cache should always include the operator namespace so that we can work with operator-internal resources,
// and the empty namespace to watch cluster-scoped resources (e.g. storage classes).
opts.NewCache = cache.MultiNamespacedCacheBuilder(append(managedNamespaces, operatorNamespace, ""))
// The managed cache should always include the operator namespace so that we can work with operator-internal resources.
managedNamespaces = append(managedNamespaces, operatorNamespace)

// Add the empty namespace to allow watching cluster-scoped resources if storage class validation is enabled.
if viper.GetBool(operator.ValidateStorageClassFlag) {
managedNamespaces = append(managedNamespaces, "")
}

opts.NewCache = cache.MultiNamespacedCacheBuilder(managedNamespaces)
}

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

0 comments on commit b7df6f4

Please sign in to comment.