Skip to content

Cluster-Wide Binding

Source: hello-pepr-ns-all

When a Capability defines namespaces: [], the module can process resources in any namespace cluster-wide. You can use .InNamespace() to filter for specific namespaces, or omit namespace filters entirely to process all namespaces.

Use namespaces: [] for:

  • Cluster-wide policies that need to apply everywhere
  • Platform-level capabilities that monitor or modify resources across all namespaces
  • Cross-namespace operations and reporting
  • Dynamic environments where namespaces are frequently created and destroyed

Important: With namespaces: [], you have maximum flexibility but also maximum scope. Use .InNamespace() filters when you need to target specific namespaces to limit the scope of your actions.

View full example on Github

When(a.ConfigMap)
.IsCreated()
.InNamespace("default")
.Mutate(function mutateDef(request) {
request.SetAnnotation("def", "seen");
});
When(a.ConfigMap)
.IsCreated()
.Mutate(function mutateNon(request) {
request.SetAnnotation("non", "seen");
});