Skip to content

Namespaces

Charles d'Avernas edited this page Nov 30, 2026 · 1 revision

Namespaces isolate tenants, teams or environments from each other on a single Cloud Streams cluster, like Kubernetes namespaces do:

  • Namespaced resources: subscriptions, sinks, feeds, gateways and brokers belong to a namespace. Their API is at /api/resources/v1/namespaces/{namespace}/{plural}, e.g. /api/resources/v1/namespaces/tenant-a/subscriptions/orders. /api/resources/v1/{plural} lists, gets and watches those of every namespace the user may read.
  • Cluster resources: schemas, which every namespace shares, and namespaces themselves, at /api/resources/v1/namespaces. Their names must be DNS labels: at most 63 lowercase letters, digits and dashes. A namespace can only be deleted once it holds no resource, and default never.
  • The default namespace is created at startup. Resources created without a namespace belong to it.

One gateway, one namespace

A gateway process serves a single gateway resource, named by CLOUDSTREAMS_GATEWAY_NAME (default by default) in the namespace CLOUDSTREAMS_GATEWAY_NAMESPACE (default by default). It creates that resource, and its namespace, if they do not exist. The events it ingests, from POST /api/events/pub or from its feeds, belong to its namespace, which it records in their $namespace metadata. That attribute is never delivered to subscribers. Its feeds and their secrets are those of its namespace.

One broker, one namespace

A broker process serves a single broker resource, named by CLOUDSTREAMS_BROKER_NAME in the namespace CLOUDSTREAMS_BROKER_NAMESPACE. It only delivers the subscriptions of that namespace, and only the events of that namespace. Like a gateway, it creates its resource and its namespace if they do not exist. Deploy a broker per namespace that has subscriptions: with the Helm chart, list them under brokers (see Kubernetes).

Events are stored in a single stream. Each namespace has its own view of it and its own partitions:

Stream Events
cloud-events every event, of every namespace
$by-namespace-{namespace} the events of a namespace, which a subscription without partition consumes
$by-source-{namespace}/{source}, $by-type-…, $by-subject-…, $by-correlation-…, $by-causation-… the events of a partition of a namespace

The stream and partition endpoints, and the MCP tools, take a namespace query parameter. Without it, they read the whole stream, which requires access to the whole cluster, and partitions of the default namespace.

Roles

The roles of Authentication:Dashboard:Roles (see Roles) grant access to every namespace. Namespaced grants a level of access within one namespace, with roles matching a template whose {namespace} and {level} placeholders are replaced with a namespace and reader, operator or admin:

Authentication:
  Dashboard:
    Roles:
      Readers: [ cloud-streams-reader ]          # every namespace
      Admins: [ cloud-streams-admin ]
      Namespaced: 'cloud-streams:{namespace}:{level}'   # e.g. 'cloud-streams:tenant-a:operator'

A user granted access to some namespaces only sees those: lists, watches, health and the namespace selector of the dashboard are filtered. Reading the whole stream and managing schemas and namespaces require the corresponding cluster role. GET /api/auth/user describes the level granted in each namespace.

Publishers

When ingestion is authenticated (see Publishers), a publisher may publish to a gateway if:

  • its token lists the gateway's namespace in the claim named by Authentication:Ingestion:NamespaceClaimType, as an array or a space-separated string. Without that setting, tokens may publish to any namespace. With it, a token without the claim may publish to none;
  • or its API key is listed under Authentication:Ingestion:Publishers with the gateway's namespace among its Namespaces, or with no Namespaces. Keys listed under ApiKeys may publish to any namespace;
  • or it is one of the gateway's own publishers, which spec.ingestion.publishers declares. Each is identified by exactly one of an API key, read from the secrets of the gateway's namespace, a Standard Webhooks signature, made with a secret of the gateway's namespace, or the subject and claims of its token, and may be bound to sources:
spec:
  ingestion:
    publishers:
      - name: orders
        apiKey: { use: orders-publisher, header: X-Api-Key }  # or { key: ... }, which is not recommended
        sources: [ 'https://orders.example.com/*' ]
      - name: billing
        subject: billing-service
        claims: { azp: billing }
      - name: payments
        signature: { use: payments-webhook }                  # its 'secret' key, and its 'previous' one while rotating it

A signed request carries the webhook-id, webhook-timestamp and webhook-signature headers, as the deliveries of a subscription whose endpoint signs them do (see Signed deliveries): a gateway can therefore verify the deliveries of a subscription of another Cloud Streams instance. The signature is computed over the request's body, which the gateway only reads before admitting the publisher if the request is signed. A request whose timestamp is more than 5 minutes off is refused.

A refused publisher gets 401 Unauthorized or 403 Forbidden, with problem type https://cloud-streams.io/problems/unauthorized-publisher or .../forbidden-publisher. Publishing from the dashboard or the MCP tools requires the operator role in the gateway's namespace.

Secrets

Each namespace reads its own secrets first, then the shared secrets, if they are shared with it (see Transports):

Provider Secrets of a namespace Shared secrets
env CLOUDSTREAMS_SECRETS__NAMESPACES__{NAMESPACE}__{NAME}__{KEY}, dashes replaced with underscores CLOUDSTREAMS_SECRETS__{NAME}__{KEY}
file {directory}/namespaces/{namespace}/{name}/{key} {directory}/{name}/{key}
kubernetes secrets labelled cloud-streams.io/namespace={namespace} secrets without that label
vault {prefix}/namespaces/{namespace}/{path} {prefix}/{path}

Shared secrets are only readable by the namespaces CloudStreams:Secrets:SharedWith lists, [ default ] by default, or by every namespace with [ "*" ]. Secret paths may not contain . or .. segments, nor anything but letters, digits, -, _ and ., so that a namespace cannot read the secrets of another one.

Clone this wiki locally