Skip to content

feat: honor agent.projectsveltos.io/watch-namespaces for agentless drift detection - #1939

Merged
gianlucam76 merged 1 commit into
projectsveltos:mainfrom
gianlucam76:namespace-scoped
Sep 1, 2026
Merged

feat: honor agent.projectsveltos.io/watch-namespaces for agentless drift detection#1939
gianlucam76 merged 1 commit into
projectsveltos:mainfrom
gianlucam76:namespace-scoped

Conversation

@gianlucam76

Copy link
Copy Markdown
Member

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.

Fixes #1932

…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.
@gianlucam76
gianlucam76 merged commit b32966e into projectsveltos:main Sep 1, 2026
11 checks passed
@gianlucam76
gianlucam76 deleted the namespace-scoped branch September 1, 2026 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow scoping drift detection watchers/RBAC to specific namespaces

1 participant