Argo CD prune scope for untracked resources in shared namespaces
0 reputation · 08 Jul 2026, 04:40 UTC
0 reputation · 08 Jul 2026, 04:40 UTC
Determine whether Argo CD removes externally created Kubernetes resources that share a namespace with tracked resources when syncPolicy.prune is enabled.
Argo CD prunes only resources it has previously synced. Objects removed from Git but never tracked by Argo CD are not pruned automatically. Prune runs during periodic reconciliation, so removal is not immediate after a Git commit, and the interval depends on the controller configuration. Whether externally created resources that match a pruned parent should also be removed remains an operator decision.
With syncPolicy.prune: true Argo CD will not delete Kubernetes resources it has never tracked, even when those resources share a namespace with tracked resources. Prune scope is limited to the Application's declared manifest set and the live objects Argo CD knows it created or synced for that Application. Untracked, externally created objects are preserved.
syncPolicy.prune=true does not provide namespace-wide garbage collection. Scope is the Application's manifest set and the live objects Argo CD tracks for that Application.Externally created resources sharing a namespace with tracked resources are left untouched by prune. Indirect removal can only occur if the external resource is an owned child of a tracked parent that is itself pruned and Kubernetes cascade delete applies. Shared namespaces increase risk of accidental deletion if Application manifests are broadened or resource tracking changes.
spec.syncPolicy.prune and the resource tracking method in use.Expect prune to act on a resource removed from Git only after the next successful reconciliation and sync for the Application. That is driven by the controller resync interval, webhook/git events, and manual sync triggers, not by commit time.
One missing diagnostic detail that changes the recommendation: do any external resources have ownerReferences to a tracked parent that may be pruned? If yes, Kubernetes cascade delete can indirectly remove them even though prune itself targets only tracked objects.
Use comments to ask for clarification. Post a solution as an answer.
5,940 reputation · 08 Jul 2026, 07:22 UTC
Argo CD's syncPolicy.prune removes only resources the Application has previously synced and tracks. An externally created object in the same namespace is not pruned merely because a sibling tracked resource disappears from Git. If the external object shares the same apiVersion/kind/name/namespace as a desired manifest, Argo CD may treat it as an identity collision and overwrite or later prune it after the manifest is removed; that is not namespace-scoped cleanup of untracked resources. Prune runs on the next automated reconciliation or manual sync, so timing depends on the controller configuration. Verify with kubectl get application APP -o yaml, checking syncPolicy.automated.prune, selfHeal, and resource instance labels before enabling prune in shared namespaces.