managedNamespaceMetadata clashing with clusterResourceWhitelist in AppProject?
#26868
Replies: 1 comment
-
|
You've identified a real architectural gap in ArgoCD — this is a known limitation tracked in issue #22869. Why it happens When Workaround: separate AppProject for namespace management The cleanest approach that fully preserves your intent is to split namespace lifecycle into its own AppProject:
# namespace-mgmt AppProject (IT-managed)
apiVersion: argoproj.io/v1alpha1
kind: AppProject
metadata:
name: namespace-mgmt
spec:
sourceRepos:
- 'https://github.com/our-org/platform-infra' # IT repo only
destinations:
- namespace: '*'
server: https://kubernetes.default.svc
clusterResourceWhitelist:
- group: ''
kind: NamespaceThis fully separates the two concerns: IT controls namespace lifecycle (including labels), developers are physically blocked from touching cluster-scoped resources. ArgoCD v3.3+ partial mitigation If you're on ArgoCD v3.3+, PR #24674 added a clusterResourceWhitelist:
- group: ''
kind: Namespace
name: 'team-a-*'This limits blast radius but doesn't fully solve your problem — a developer can still include a On filing a feature request Yes, it's absolutely worth it. The exact feature that's been proposed (but not implemented) is an In the meantime, the separate AppProject approach is the most robust path forward. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to set up Argo with a separation of responsibilities - between "IT" that manage Argo itself via a Git repo containing AppProjects and ApplicationSets, and developers who manage their own app repos (containing Kustomize manifests in a
deploy/directory). The ApplicationSet discovers apps via a Git file generator and deploys each into its own namespace. The expectation was that we could use Argo'sCreateNamespaceoption to create the Namespace for each app, which would allow our AppProject to forbid developers from creating Namespaces at all.However it seems that when using the
managedNamespaceMetadataoption to attach some labels to the auto-created Namespace, it fails with:Looking at the source code in
sync_namespace.go, whenManagedNamespaceMetadatais non-nil, ArgoCD adds the Namespace to the sync task list as a resource, which then gets checked against the AppProject'sclusterResourceWhitelist.Adding
NamespacetoclusterResourceWhitelistfixes the sync, but it defeats the purpose of our approach - developers could then include anamespace.yamlin their app manifests and create arbitrary namespaces with whatever labels they want.managedNamespaceMetadatawithout opening upclusterResourceWhitelistto Namespace? It seems like the namespace metadata set by the ApplicationSet (which IT controls) should be treated differently from namespace resources in the app manifests (which developers control).clusterResourceWhitelistwithresourceNamesto restrict which namespaces can be created, but the allowed names vary per-app and can't be templated in a shared AppProject.CreateNamespace=true+managedNamespaceMetadata, since it's controlled by the Application spec (not the app manifests)?For reference, our
external-appsAppProject is intentionally restrictive:and the syncPolicy:
Beta Was this translation helpful? Give feedback.
All reactions