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.
When to Use
Section titled “When to Use”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.
Code Example
Section titled “Code Example”View full example on Github
Filter for Specific Namespace
Section titled “Filter for Specific Namespace”When(a.ConfigMap) .IsCreated() .InNamespace("default") .Mutate(function mutateDef(request) { request.SetAnnotation("def", "seen"); });Process All Namespaces
Section titled “Process All Namespaces”When(a.ConfigMap) .IsCreated() .Mutate(function mutateNon(request) { request.SetAnnotation("non", "seen"); });