feat: honor agent.projectsveltos.io/watch-namespaces for agentless drift detection - #1939
Merged
Merged
Conversation
…ift detection A managed cluster can be annotated with `agent.projectsveltos.io/watch-namespaces` (comma-separated namespace list on the Cluster/SveltosCluster). This is passed to drift-detection-manager created in **agentless mode** for a given managed cluster. 1. **drift-detection-manager** will start namespace watchers instead of one cluster wide. 2. **addon-controller's own stale-resource search.** `processDeployedGVKs` now reads the same annotation and, for namespaced GVKs, fans out the stale-resource `List` calls (new `listDeployedResources` helper) to only the configured namespaces instead of listing cluster-wide. This keeps the RBAC-restricted remote-cluster credential inside its granted scope for cleanup, the same way it already has to be for the initial deploy. Without this, an agentless cluster whose credential is RBAC-restricted to a subset of namespaces has no way to tell drift-detection-manager or addon-controller's stale-resource search to stay inside that subset. Noth would (or already do, for drift-detection-manager) attempt cluster-wide operations and fail with Forbidden the moment they touch a namespace outside the granted RBAC.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
A managed cluster can be annotated with
agent.projectsveltos.io/watch-namespaces(comma-separated namespace list on the Cluster/SveltosCluster). This is passed to drift-detection-manager created in agentless mode for a given managed cluster.drift-detection-manager will start namespace watchers instead of one cluster wide.
addon-controller's own stale-resource search.
processDeployedGVKsnow reads the same annotation and, for namespaced GVKs, fans out the stale-resourceListcalls (newlistDeployedResourceshelper) to only the configured namespaces instead of listing cluster-wide. This keeps the RBAC-restricted remote-cluster credential inside its granted scope for cleanup, the same way it already has to be for the initial deploy.Without this, an agentless cluster whose credential is RBAC-restricted to a subset of namespaces has no way to tell drift-detection-manager or addon-controller's stale-resource search to stay inside that subset. Noth would (or already do, for drift-detection-manager) attempt cluster-wide operations and fail with Forbidden the moment they touch a namespace outside the granted RBAC.
Fixes #1932