Commit c1a447b
authored
docs(tenants): document namespace layout and parent/child derivation (#479)
## What
Adds two new sections to the Tenant System guide
(`/docs/v1/guides/tenants/`) that document how tenant workload namespace
names are constructed and how downstream integrations should walk the
tenant tree without string-parsing namespace names.
## Why
Tenant workload namespaces follow two different rules depending on
depth: tenants created directly under `tenant-root` get a flat name
(`tenant-alpha`), while tenants created at any deeper level get a
hierarchical name (`tenant-alpha-beta`, `tenant-alpha-beta-gamma`). This
split is not documented anywhere in `content/en/docs/v1/`, so anyone
building dashboards, audit tooling, cost-allocation jobs, or policy
engines on top of Cozystack has to infer it from the chart templates.
The natural first attempt — `strings.Split(namespace, "-")` to derive a
parent — is wrong for one of the two cases regardless of which heuristic
you pick, and integrations that try it run into silent breakage on
root-level or deep-level tenants.
The new material:
- **Tenant Namespace Layout** — states the two rules plainly, shows a
four-row lookup table from `root` down to `root/alpha/beta/gamma`, and
links to the two source-of-truth files
(`packages/apps/tenant/templates/_helpers.tpl` and
`pkg/registry/apps/application/rest.go::computeTenantNamespace`) so a
reader can audit the claim against the implementation.
- **Deriving Parent and Child Relationships** — explains why
string-parsing the namespace is unreliable and documents the `Tenant` CR
fields that should be used instead: `metadata.namespace` always equals
the parent's workload namespace, `status.namespace` equals the tenant's
own workload namespace, and listing children of a tenant with workload
namespace `N` is `list Tenants where metadata.namespace == N`. This
pattern is stable regardless of whether the tenant is a direct child of
`tenant-root` or a deeper descendant.
No existing content is moved or rewritten; the sections are inserted
between *Tenant Naming Limitations* and *Reference*, where readers
looking for naming details will naturally land.
## Verification
- `hugo` builds cleanly; the tenants guide renders with both new
sections.
- Table entries cross-checked against
`packages/apps/tenant/templates/_helpers.tpl::tenant.name` in the
current cozystack tree (the helper fails the Helm release if the tenant
name itself contains a dash, which is why the "namespace fragments never
contain tenant-internal dashes" note is accurate).
- The "`metadata.namespace` equals the parent's workload namespace"
claim matches Kubernetes semantics — `Tenant` CRs are namespace-scoped
and stored in the parent's workload namespace by construction.
- The aggregated API code path
(`pkg/registry/apps/application/rest.go::computeTenantNamespace`)
implements the same flat/hierarchical split, so `status.namespace` on a
`Tenant` CR is a reliable mirror of the workload namespace.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **Documentation**
* Added a tenant namespace layout describing deterministic derivation
with an example table
* Guidance for integrations on determining parent vs tenant workload
namespaces, plus a kubectl example
* Documented RFC‑1123 naming constraints, a 63‑character limit for
deeper names, and the failure mode when derivation is rejected
* Minor formatting and cleanup for clarity
<!-- end of auto-generated comment: release notes by coderabbit.ai -->1 file changed
Lines changed: 85 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
100 | 185 | | |
101 | 186 | | |
102 | 187 | | |
| |||
0 commit comments