Open
Description
Inside "sigs.k8s.io/controller-runtime/pkg/cache".Options The option for DefaultNamespaces
should select the namespaces in which the cache watches.
When setting the cache to watch dynamic namespaces that should be identified through a label selector the cache refuses to sync properly, when attempting to get a secret from such namespace, it returns the error:
failed to get secret: /v1, Kind=Secret is not cached.
code example:
labelRequirements, err := labels.NewRequirement(
"key", selection.In, []string{"value1", "value2"})
cacheOpts := cache.Options{
DefaultNamespaces: map[string]cache.Config{
cache.AllNamespaces: cache.Config{
LabelSelector: labels.NewSelector().Add(*labelRequirements),
},
},
ReaderFailOnMissingInformer: true,
SyncPeriod: &syncTimer,
}
....
When replacing the cache.AllNamespaces
string with the name of the namespaces and removing the label selector it works properly.