Skip to content

Design: How should substrate use (or not use) namespaces in a Kubernetes cluster? #18

Open

Description

@thockin

Current state:

Not a ton of thought has gone into the current design.

ActorTemplates

CRDs are cluster-global, but the CRs they describe can be namespaced. ActorTemplate is a namespaced CR. The substrate code today pays attention to all ActorTemplates, regardless of namespace. Most of the UX involves specifying templates as a tuple of {namespace, name}. For example: kubectl ate create actor foo --template bar/my-template creates an actor named "foo" from the ActorTemplate named "my-template" in k8s namespace "bar".

WorkerPools

Like ActorTemplate, WorkerPool is a namespaced CRD which is ultimately manifested as k8s pods in that same namespace.

Control plane

To run Agent Substrate, we need a namespace in which to run a bunch of stuff, such as the control plane.

How should substrate use k8s namespaces?

Kubernetes namespaces are generally used for separating teams or “tenants”, environments (staging vs. prod), service producers, for managing quota and charge-backs, and many other reasons.

So now we need to answer a fundamental question - is a substrate a cluster level concept (i.e. any cluster can have at most 1 substrate) or can a single cluster run multiple instances of substrate?

It seems obvious (to me) that a single cluster should be able to run multiple instances of the substrate. So how would one deploy two instances of it in a cluster? Obviously, those would go into different namespaces, but exactly how to map those is not obvious.

"Workers" are analogous to Kubernetes Nodes. Kubernetes Nodes are not namespaced, which means that Pods can share a Node even if the Pods are from different Namespaces. From that point of view it seems natural that Workers shouldn't be namespace, either. Especially if we want cluster-wide worker-pools that are fungible across actors. But do we?

If a cluster can be "multi-tenant" (with varying levels of hard/soft isolation possible), then a cluster-wide ANYTHING will be trouble. In fact, it's probably not controversial to say that many of the “cluster scoped” (non-namespaced) concepts in Kubernetes are considered problematic in hindsight.

On the other hand, Kubernetes Pods are namespaced, and Workers are implemented as Pods. Making Workers non-namespaced while still semantically linked to a Pod would require complex extra work, and will forever be a vector for security issues. We should not make the presumed multi-tenancy requirements worse. Instead, all of the Workers for a given substrate instance can be k8s Pods within that substrate’s k8s Namespace(s), and those Workers would only service that single instance of substrate.

As shown above, substrate already uses multiple namespaces, and we probably don't want to put things like ActorTemplates (which are part of using substrate) in a namespace with the control plane. It's likely that different personas will use those. So every instance of substrate needs 2 namespaces. At least.

We should probably support a model which uses multiple namespaces for ActorTemplates, and possible for Workers (e.g. to segregate different groups of Workers from each other). Sp really substrate needs a way to say:

  • My control plane is in namespace A
  • My workerpools are in namespaces B, C, D...
  • My ActorTemplates are in namespaces E, F, G...

The usual way to do N-ary things in kubernetes is label selectors.

This model naturally aligns to many of the other primitives we've got in Kubernetes such as workload autoscaling, Gateway and HTTP routes, etc. Some things like network policies can be made to work across namespaces. Some things like quota become more difficult.

Activity

  1. mtaufen commented on May 22, 2026

    @mtaufen
    Collaborator

    My ActorTemplates are in namespaces E, F, G...

    If ActorTemplates are in K8s namespaces, do we need an import mechanism to bring them into substrate namespaces? Do we need an export mechanism on the K8s side to determine which substrate namespaces are allowed to import a given template?

  2. mtaufen commented on May 22, 2026

    @mtaufen
    Collaborator

    Hmm, another question: Should substrate namespaces be represented by CRDs in K8s, or invisible at the K8s layer and just hosted in ate-api?

  3. thockin commented on May 31, 2026

    @thockin
    CollaboratorAuthor

    Today ActorTemplate is not represented in the substrate API at all, which ...is weird. Creating an actor from a template requires the caller to understand and exist in both planes of existence. I think that's awkward at best, and quite possibly just wrong.

    There's an ongoing discussion about Secrets and ConfigMaps being exposed via ActorTemplate (#15), which relies on k8s Namespaces as the boundary, which is probably important.

    Should substrate namespaces be represented by CRDs in K8s, or invisible at the K8s layer and just hosted in ate-api?

    Interesting idea. Should substrate-accessible secrets follow the same pattern? E.g:

    Kind: SecretRef
    apiVersion: cfg.ate.dev/v1
    secretName: the-secret
    
  4. added
    prio/P1
    on May 31, 2026
  5. zlammerts-svg commented on Jul 19, 2026

    @zlammerts-svg
    Collaborator

    Haven, I'm assigning all namespace related work to you. Please review and triage. Thanks!

  6. HavenXia commented on Jul 22, 2026

    @HavenXia
    Member

    Triaged as the atespace owner - #21 and this issue were two halves of one question.

    The substrate-side half is resolved: substrate now has its own grouping concept, atespace — an substrate-native object, invisible at the k8s layer, decoupled from k8s namespaces. Actors are named, grouped, identified and DNS-routed by atespace.

    The k8s-side half has split by resource (see #368):

    • Workers: settled direction — Worker becomes the substrate scheduling primitive via ateapi; WorkerPool leaves the substrate API and survives only as a Kubernetes-provider implementation detail (worker labels already moved into the ate plane in controlapi: Add worker pool metadata to workers #403).

    • ActorTemplates: staying as namespaced k8s CRD for now. For templates the questions here stay live: the k8s-namespace ↔ atespace relationship, and which templates may instantiate actors in which atespaces?

    This is tracked as atespace resource grants, which should be part of atespace quota as a P1 task, deferred until we got actual customer need on it.

  7. HavenXia commented on Jul 22, 2026

    @HavenXia
    Member

    One question keeps independent: can a single cluster run multiple substrate instances? Intuition is true but it's a P1 that we listed but haven't scoped into any milstone.

    This issue should be kept open for record.

  8. added
    kind/feature
    on Aug 13, 2026
  9. added
    kind/design
    on Sep 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area/apiarea/api-machinerykind/designkind/featureprio/P1

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions