# Namespaces and limits

> For the complete documentation index, see [llms.txt](https://docs.ringleader.dev/llms.txt).


> A namespace is the unit of tenancy for a team, and limits cap how many workstations run in a namespace or an organization at once.


A namespace is the unit of tenancy for a team or business unit, and every resource lives in one. Limits cap what runs in a namespace or in a whole organization at once, which is what costs money in your cloud account.

The fields of a namespace are in the [Namespace](https://docs.ringleader.dev/reference/resources/namespace/) reference, and those of its organization are in [Organization and OrgDomain](https://docs.ringleader.dev/reference/resources/organization/).

## Namespaces

Every resource lives in one namespace, and its cross-references stay within it. Two kinds are the exception:

- A `CloudAccount` is cluster-scoped and owned by an organization, not a namespace. A CloudIdentity may only reference an account that belongs to the organization its own namespace belongs to.
- A `LocalBinding` stays on the computer that created it and is never synced or mirrored.

A namespace belongs to at most one [organization](https://docs.ringleader.dev/organizations-teams/accounts-access/organizations-domains/). Ringleader does not create a namespace until you sign in for the first time. [Organization membership](https://docs.ringleader.dev/organizations-teams/accounts-access/organizations-domains/#organization-membership) says which namespace you land in. Working locally without signing in, you get the reserved `local` namespace, which also holds the local container runtime.

When you leave out `-n`, the command line picks a namespace for you. [Namespaces and resolution](https://docs.ringleader.dev/reference/cli/#namespaces-and-resolution) gives the order, and `rl namespace use` selects one for the device.

### Namespace names

If you are an organization administrator, name a new namespace after its organization: `<org>` or `<org>-<name>`, such as `acme` or `acme-engineering`. Ringleader refuses any other name, and its error suggests one that starts with `<org>-`. The rule applies only when you create a namespace, so a namespace that already exists keeps its name. [`rl namespace create <name>`](https://docs.ringleader.dev/reference/cli/commands/imperative-creation/#rl-namespace-create-name) has the details.

## Limits

A limit is a number you set on a namespace or an organization. Two kinds are available:

- **A namespace count.** `spec.maxNamespaces` on an organization bounds how many namespaces belong to it.
- **Running limits.** `maxRunningWorkstations`, `maxVCPUs` and `maxGPUs` bound how many workstations run at once. They also bound how many vCPUs and GPUs running cloud workstations use between them. Set them on an organization, for all of its namespaces together, or on a namespace, for that namespace alone.

The fields are in [Limit fields](https://docs.ringleader.dev/reference/resources/namespace/#limit-fields). Each running limit is unset by default, and unset means no limit. `0` is a limit: with `maxGPUs: 0`, no cloud workstation with a GPU can start.

Only Ringleader can change a limit on an organization, including its namespace count. On a namespace, an `org-admin` of its organization or Ringleader sets the running limits, and a `namespace-admin` cannot.

### Namespace count limit

A write that would add a namespace to an organization already at its limit is refused, and the error names the organization and the limit. Editing or deleting the namespaces an organization already has is never affected, even at the limit.

- The default is 50. An organization created before the field existed enforces the same number.
- A personal organization, the one Ringleader creates for a solo self-serve signup, is limited to 10 instead. Organizations onboarded before that keep whatever they have.
- There is no unlimited value. An organization that needs more gets a larger explicit number.
- An `org-admin` can read the field but cannot raise their own limit.

### Running limits

When you create a workstation that is not stopped, or start a stopped one, Ringleader checks both the namespace's limits and its organization's. If the start would go over one, Ringleader refuses it. The message names the limit, which it calls a cap, its value and what is in use:

```text
starting this workstation would take namespace "acmecorp-team-a" over its vCPU cap: maxVCPUs is 64, 60 are in use and this workstation needs 8
```

Stopping a workstation is never refused, and neither is editing one that is already running, so you can always get back under a limit. A workstation pool's members are checked like any other workstation, as [Pool failures](https://docs.ringleader.dev/workstations/lifecycle/pools-leases/#pool-failures) describes. A start by a Ringleader operator is not checked.

What counts, and how a cloud workstation is sized:

- A workstation counts as running from the moment you create it running or start it, until you stop it or delete it.
- A cloud workstation's vCPUs and GPUs are those of its machine type, as the [CloudIdentity](https://docs.ringleader.dev/reference/resources/cloudidentity/) that places it lists them. `rl cloudidentity machine-types <name>` shows that list.
- If Ringleader cannot tell a size, it refuses the start and says so. That happens when the CloudIdentity's list does not include the machine type, or Ringleader has not fetched the list yet. A running workstation of unknown size in the same namespace or organization refuses a start that adds vCPUs or GPUs, for the same reason.

### Over-limit stops

A namespace or organization can still end up over a limit. Two starts at the same moment can both pass, someone can lower a limit, and resizing a running workstation is not checked. Ringleader looks at each namespace and organization that sets a limit once a minute. When one is over, Ringleader stops workstations until it is back at the limit. It stops idle pool members first, then other workstations, the most recently started first.

Ringleader never stops these:

- A local workstation, for a vCPU or GPU limit.
- A leased pool member.
- A [node-bound](https://docs.ringleader.dev/workstations/basics/#node-bound-workstations) workstation, which its own computer runs.
- A workstation being deleted.
- A workstation a Ringleader operator owns.

A workstation that Ringleader stops shows `status.stopCause: RunningCap`. It starts again only when its owner starts it.

## Create a namespace

Create a namespace for a team when you are an `org-admin`. The namespace must name your own organization, or Ringleader denies it.

Run `rl namespace create acme-engineering --org acme`. If you can see only one organization, leave out `--org`, and the command uses it and names it on stderr.

You can also write the namespace as a file and apply it with `rl apply`:

```yaml
apiVersion: core.ringleader.dev/v1
kind: Namespace
metadata: { name: acmecorp-team-a }
spec: { org: acmecorp }
```

## Set a namespace's limits

Set running limits on a namespace when one team should not use more than its share of your cloud account. You must be an `org-admin` of the namespace's organization.

1. Add the limits to the namespace's `spec`. Set only the ones you want, because an unset limit means no limit:

   ```yaml
   apiVersion: core.ringleader.dev/v1
   kind: Namespace
   metadata: { name: acmecorp-team-a }
   spec:
     org: acmecorp
     maxRunningWorkstations: 10
     maxVCPUs: 64
     maxGPUs: 2
   ```

2. Run `rl apply -f team-a.yaml`. Ringleader checks the new limits on the next start in the namespace.

## Next steps

- [Organizations and domains](https://docs.ringleader.dev/organizations-teams/accounts-access/organizations-domains/): how a namespace gets its organization.
- [Roles and grants](https://docs.ringleader.dev/organizations-teams/accounts-access/roles-grants/): give people a role in the namespace.
- [Starts, stops and restarts](https://docs.ringleader.dev/workstations/lifecycle/starts-stops-restarts/): how a refused start looks to the person who runs it.

