You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Feature Request: Allow ArtifactGenerator to create ExternalArtifact in other namespaces #354
A common use case Flux users have is a multi-tenant monorepo containing the YAML for all tenants. ArtifactGenerator does not support it today because it can only create ExternalArtifact in the same namespace as the ArtifactGenerator, which breaks multi-tenancy i.e. it requires cross-namespace source references in appliers, which in a multi-tenant setup are blocked.
For allowing ExternalArtifact to be created in a different namespace (i.e. not the namespace of the ArtifactGenerator producing it), we need to introduce two fields:
.spec.artifacts[].namespace
.spec.serviceAccountName
Like a Flux Kustomization or Flux Operator ResourceSet, ArtifactGenerator inherits the controller RBAC, which normally allows it to create ExternalArtifact in any namespace. When .spec.serviceAccountName is not specified and multi-tenancy lockdown is not enabled, the controller uses its own credentials, so ExternalArtifact can be created in any namespace.
When .spec.serviceAccountName is specified, source-watcher will impersonate the ServiceAccount for reconciling the ExternalArtifact objects. This means the ServiceAccount will require the necessary RBAC bindings, and its RBAC bindings define which namespaces the ArtifactGenerator can touch. Because RBAC allows a namespaced RoleBinding to bind a namespaced Role to a ServiceAccount from another namespace (the RoleBinding subject has a namespace field), this will allow ExternalArtifact to be created in other namespaces, which in turn will allow cross-namespace source references to remain blocked for multi-tenant setups.
Multi-tenancy lockdown forces a .spec.serviceAccountName. Cluster admins can enforce this by starting the controller with the --default-service-account flag, which is used as the .spec.serviceAccountName when the field is not specified.
changed the title [-]Feature Request: Allow AritfactGenerator to create ExternalArtifact in other namespaces[/-][+]Feature Request: Allow ArtifactGenerator to create ExternalArtifact in other namespaces[/+]on Jun 29, 2026
One use-case for this is monorepo decoupling where the GitRepository and ArtifactGenerator sit in the flux-system namespace, while the generated ExternalArtifact objects should target tenant namespaces.
If we allow cross-namespace under impersonation, then cluster admins can use the same ResourceSet to generate the tenant namespaces + RBAC + kustomizations and also include an ArtifactGenerator that splits the monorepo into artifacts per tenant namespace.
Reacted by Matheus Pimenta and Terdunov Vyacheslav
CRD XValidation via CEL expressions must block .namespace from being used when .serviceAccountName is not specified.
Actually, that's not how ResourceSet behaves.
A major use case we are planning to support is generating Flux Kustomizations dynamically with ArtifactGenerator.spec.pathPattern using ResourceSet. ResourceSet generates the appliers i.e. the Flux Kustomizations in any target namespace. Like a Flux Kustomization, Flux Operator ResourceSet inherits the controller RBAC, which in both cases is normally cluster-admin, which allows them to create things in any namespace. Multi-tenancy lockdown forces a .spec.serviceAccountName in both cases, which is how users can define what namespaces the Kustomization / ResourceSet can touch.
ArtifactGenerator should be no different. It should be allowed to create ExternalArtifact in any namespace if .spec.serviceAccountName is not specified and multi-tenancy lockdown is not enabled.
Hi, I’d like to take #354, but before starting implementation I’d like to align on the intended semantics.
My understanding of the proposed scope is to add an optional .spec.artifacts[].namespace and an optional .spec.serviceAccountName. When namespace is omitted, the current same-namespace behavior would remain unchanged. For permitted cross-namespace output without a ServiceAccount, the controller’s credentials would be used. When a ServiceAccount is specified, operations on the resulting ExternalArtifact resources would use impersonation.
I’d like to clarify a few points before proceeding. May .spec.artifacts[].namespace contain {capture} substitutions from pathPattern? My understanding from Matheus’s comment is that multi-tenancy lockdown requires serviceAccountName for cross-namespace output; should this rule be enforced specifically through the existing --no-cross-namespace-refs mode and apply to output artifacts configured via .spec.artifacts[].namespace? Which operations must use impersonation: apply, status updates, get, and delete, or the broader reconciliation flow? How should cleanup work if the configured namespace or ServiceAccount changes, or if the ServiceAccount or other identity used for cleanup loses the required permissions?
For testing, I would cover backward compatibility for same-namespace output, cross-namespace output using both controller credentials and a ServiceAccount, and failure behavior when RBAC permissions are insufficient. I would also verify inventory tracking, drift detection, moving artifacts between namespaces, and artifact deletion, including cleanup behavior. The implementation would include the required CRD and deepcopy updates together with documentation for the new fields, authorization behavior, and backward-compatibility behavior. Since the change is additive, existing configurations would not require migration.
Please confirm whether these boundaries and open questions match the maintainers’ expectations before I begin implementation.
Activity
[-]Feature Request: Allow AritfactGenerator to create ExternalArtifact in other namespaces[/-][+]Feature Request: Allow ArtifactGenerator to create ExternalArtifact in other namespaces[/+]stefanprodan commentedon Jun 29, 2026
One use-case for this is monorepo decoupling where the
GitRepositoryandArtifactGeneratorsit in the flux-system namespace, while the generatedExternalArtifactobjects should target tenant namespaces.If we allow cross-namespace under impersonation, then cluster admins can use the same ResourceSet to generate the tenant namespaces + RBAC + kustomizations and also include an
ArtifactGeneratorthat splits the monorepo into artifacts per tenant namespace.matheuscscp commentedon Jul 3, 2026
Actually, that's not how ResourceSet behaves.
A major use case we are planning to support is generating Flux Kustomizations dynamically with
ArtifactGenerator.spec.pathPatternusing ResourceSet. ResourceSet generates the appliers i.e. the Flux Kustomizations in any target namespace. Like a Flux Kustomization, Flux Operator ResourceSet inherits the controller RBAC, which in both cases is normallycluster-admin, which allows them to create things in any namespace. Multi-tenancy lockdown forces a.spec.serviceAccountNamein both cases, which is how users can define what namespaces the Kustomization / ResourceSet can touch.ArtifactGenerator should be no different. It should be allowed to create ExternalArtifact in any namespace if
.spec.serviceAccountNameis not specified and multi-tenancy lockdown is not enabled.ruslan-shaydullin commentedon Aug 31, 2026
Hi, I’d like to take #354, but before starting implementation I’d like to align on the intended semantics.
My understanding of the proposed scope is to add an optional
.spec.artifacts[].namespaceand an optional.spec.serviceAccountName. Whennamespaceis omitted, the current same-namespace behavior would remain unchanged. For permitted cross-namespace output without a ServiceAccount, the controller’s credentials would be used. When a ServiceAccount is specified, operations on the resultingExternalArtifactresources would use impersonation.I’d like to clarify a few points before proceeding. May
.spec.artifacts[].namespacecontain{capture}substitutions frompathPattern? My understanding from Matheus’s comment is that multi-tenancy lockdown requiresserviceAccountNamefor cross-namespace output; should this rule be enforced specifically through the existing--no-cross-namespace-refsmode and apply to output artifacts configured via.spec.artifacts[].namespace? Which operations must use impersonation: apply, status updates, get, and delete, or the broader reconciliation flow? How should cleanup work if the configured namespace or ServiceAccount changes, or if the ServiceAccount or other identity used for cleanup loses the required permissions?For testing, I would cover backward compatibility for same-namespace output, cross-namespace output using both controller credentials and a ServiceAccount, and failure behavior when RBAC permissions are insufficient. I would also verify inventory tracking, drift detection, moving artifacts between namespaces, and artifact deletion, including cleanup behavior. The implementation would include the required CRD and deepcopy updates together with documentation for the new fields, authorization behavior, and backward-compatibility behavior. Since the change is additive, existing configurations would not require migration.
Please confirm whether these boundaries and open questions match the maintainers’ expectations before I begin implementation.