Multi-Namespace scoping and NerdGraph Provider #1866
+1,006
−102
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Contribution Details
PR Description
This PR adds two significant enhancements to Flagger:
Namespace Scoping Support - Allows Flagger to watch specific namespaces instead of all namespaces #1859
New Relic NerdGraph Provider - Adds support for New Relic's GraphQL API for custom metrics #1860
What This PR Does
Namespace Scoping Feature
Problem: Previously, Flagger could only watch all namespaces in a cluster, which wasn't ideal for multi-tenant environments or when you only want to manage canaries in specific namespaces.
Multi-Tenancy Issues:
Security Isolation: Watching all namespaces meant Flagger had cluster-wide permissions and could potentially access sensitive deployment information across tenant boundaries.
Resource Conflicts: Multiple teams using Flagger in the same cluster could experience naming conflicts or unintended interactions between their canary configurations.
Compliance Requirements: Organizations may have strict compliance requirements that mandate workload isolation between different business units, environments, or customers.
Operational Challenges:
Noise and Complexity: Operators had to sift through logs and metrics from all namespaces, making troubleshooting and monitoring more difficult when they only cared about a specific namespace.
RBAC Complexity: Organizations couldn't implement least-privilege access patterns where Flagger instances should only have permissions for specific namespaces they're responsible for managing.
Environment Separation:
Development vs Production: Teams often want separate Flagger instances for different environments, but the all-namespace approach made it impossible to cleanly separate development canaries from production ones.
Staged Rollouts: Organizations implementing progressive delivery across multiple environments need better control over which Flagger instance manages which namespace.
This limitation forced many organizations to either:
Solution: Modified --namespace flag that accepts a comma-separated list of namespaces to watch.
Key Changes:
Modified:
cmd/flagger/main.goto parse namespace flag and create namespace-specific informerspkg/controller/to handle both namespace-specific and all-namespace listersNew Relic NerdGraph Provider
Problem: The existing New Relic provider only used the Insights API. New Relic currently recommends using the NerdGraph (GraphQL) API. This is also the API we use at Capital One.
Solution: Implemented a NerdGraph provider that wraps NRQL queries in GraphQL and supports template variables.
Key Features:
{{ target }},{{ namespace }}, etc.)Implementation Details:
Added :
pkg/metrics/providers/newrelic-nerdgraph.gowith full provider implementationpkg/metrics/providers/newrelic-nerdgraph_test.go