Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ jobs:
-e RATE_LIMIT_WRITES_PER_MINUTE=60 \
-e RATE_LIMIT_BURST=10 \
-e MAX_IMAGES_PER_TENANT=20 \
-e MAX_PROFILES_PER_TENANT=20 \
-e INCUS_URL=https://incus.example.org \
-e INCUS_CLIENT_ID=ci-incus \
-e OIDC_TOKEN_URL=https://auth.example.org/application/o/token/ \
Expand Down
2 changes: 1 addition & 1 deletion cmd/phorge-api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func main() {
InstanceBootGrace: cfg.InstanceBootGrace, InstanceStuckAfter: cfg.InstanceStuckAfter,
KeyMaxLifetime: cfg.APIKeyMaxLifetime,
MaxTenantsPerUser: cfg.MaxTenantsPerUser,
RateLimitPerMinute: cfg.RateLimitPerMinute, RateLimitBurst: cfg.RateLimitBurst, MaxImagesPerTenant: cfg.MaxImagesPerTenant, MaxProfilesPerTenant: cfg.MaxProfilesPerTenant,
RateLimitPerMinute: cfg.RateLimitPerMinute, RateLimitBurst: cfg.RateLimitBurst, MaxImagesPerTenant: cfg.MaxImagesPerTenant,
},
})
srv := &http.Server{Addr: cfg.ListenAddr, Handler: srvAPI.Handler(), ReadHeaderTimeout: 10 * time.Second}
Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Pages are grouped by what the reader wants, following [the organization's docume
| [Networks](reference/networks.md) | Behavior of the network routes |
| [Memberships and API keys](reference/memberships-and-api-keys.md) | Roles and personal keys |
| [Terminal](reference/terminal.md) | Opening, protocol, closing codes and limits of a terminal |
| [Limits and quotas](reference/limits-and-quotas.md) | The plan of a tenant, the images, the rate of a caller |
| [Limits and quotas](reference/limits-and-quotas.md) | What every tenant may hold, the images, the rate of a caller |

## Explanation

Expand Down
7 changes: 4 additions & 3 deletions docs/reference/configuration.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
type: reference
audience: operator who deploys or configures the API
verified: 2026-11-06
verified: 2026-11-11
---

# Configuration
Expand All @@ -22,8 +22,7 @@ Configuration is read from the environment and the process refuses to start, lis
| `INSTANCE_BOOT_GRACE` | yes | How long after a creation or a start a stop is refused (`409`, `starting`): a stop sent while the guest boots is lost and then hangs, and nothing Incus or Crossplane report says when the system inside listens (measured: the address and the interfaces are there before the agent). `0` never refuses |
| `INSTANCE_STUCK_AFTER` | yes | How long a start or a stop may last before it is reported in `problems` |
| `API_KEY_MAX_LIFETIME` | yes | The longest an API key lives: its `expiresAt` is capped to it. `0` caps nothing. A key always has an expiry, whatever the value |
| `MAX_PROFILES_PER_TENANT` | yes | How many profiles the users of a tenant may make (the three every tenant has do not count). Over it the answer is `409` with the code `quota_exceeded`. `0` is no limit |
| `MAX_TENANTS_PER_USER` | yes | How many tenants a person may own, whoever created them. Any person signed in with Authentik creates their own, with the `small` plan. Over it the answer is `409` with the code `quota_exceeded`. `0` is no limit |
| `MAX_TENANTS_PER_USER` | yes | How many tenants a person may own, whoever created them. Any person signed in with Authentik creates their own. Over it the answer is `409` with the code `quota_exceeded`. `0` is no limit |
| `RATE_LIMIT_WRITES_PER_MINUTE` | yes | How many requests that create, change or delete one caller (a person or a key) may send a minute. Over it the answer is `429` with `Retry-After`. `0` limits nothing. It is kept in the memory of one replica: with several, a caller gets the limit of each |
| `RATE_LIMIT_BURST` | yes | How many such requests a caller may send at once before the rate applies, at least `1` |
| `MAX_IMAGES_PER_TENANT` | yes | How many images a tenant may hold. Over it the answer is `409` with the code `quota_exceeded`. `0` is no limit |
Expand All @@ -38,3 +37,5 @@ Configuration is read from the environment and the process refuses to start, lis
| `TERMINAL_RECHECK_INTERVAL` | yes | How often the right of the person and the state of the instance are checked again while a terminal is open, at least `1s`. Incus does not end a session whose right was removed, so the API does |

Nothing that decides how the API behaves has a default in the code: a value is written in the deployment, where it is seen. The format constants (the `apikey-` prefix of the account of a key, the names of the annotations, how long creating a key waits for Crossplane) stay in the code.

`MAX_PROFILES_PER_TENANT` is no longer read: how many profiles a tenant may make is the same limit for every tenant, 2, written in the code (see [Limits and quotas](limits-and-quotas.md)). A deployment that still sets it starts as before, the variable is ignored, and it can be removed from the deployment.
4 changes: 2 additions & 2 deletions docs/reference/endpoints.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ verified: 2026-11-08
| `GET /v1/whoami` | Who the credential stands for |
| `GET /v1/limits` | What the API enforces on a request: the bounds of an instance and the value each takes when a request leaves it out, the longest names, and the ceilings of the deployment (profiles and images per tenant, tenants per person). Any credential; nothing about a tenant |
| `GET /v1/tenants`, `GET /v1/tenants/{t}` | The tenants you hold a role on |
| `POST /v1/tenants`, `PATCH /v1/tenants/{t}`, `DELETE /v1/tenants/{t}` | Create a tenant for yourself (plan `small`), rename and delete it (its admins, the owner among them) |
| `POST /v1/tenants`, `PATCH /v1/tenants/{t}`, `DELETE /v1/tenants/{t}` | Create a tenant for yourself (every tenant has the same limits), rename and delete it (its admins, the owner among them) |
| `GET`, `POST /v1/tenants/{t}/images`, `GET`, `DELETE /v1/tenants/{t}/images/{name}` | The images of a tenant: read with a role or a key tuple (`images:read`), write with `operator` or `images:write` |
| `GET /v1/tenants/{t}/quota` | What the plan of the tenant allows (instances, vCPU, memory, disk, networks) and what it holds. Read with the right of the instances |
| `GET /v1/tenants/{t}/quota` | What a tenant may hold (instances, vCPU, memory, disk, networks, profiles; the same for every tenant) and what it holds. Read with the right of the instances |
| `GET`, `POST /v1/tenants/{t}/profiles`, `GET`, `DELETE /v1/tenants/{t}/profiles/{name}` | The sizes an instance can take: the profiles `s`, `m` and `l` every tenant is created with, and the ones its users make. Read with any role or `profiles:read`, write with `operator` or `profiles:write` |
| `GET`, `POST /v1/tenants/{t}/networks`, `GET`, `PATCH`, `DELETE /v1/tenants/{t}/networks/{name}` | The networks of a tenant, which comes without one: read with a role (`viewer` and above) or `networks:read`, write with `operator` or `networks:write` |
| `GET`, `POST /v1/tenants/{t}/memberships`, `GET`, `DELETE /v1/tenants/{t}/memberships/{name}` | The roles of the users: admins of the tenant, and the keys with `memberships:read` and `memberships:write` on it |
Expand Down
8 changes: 4 additions & 4 deletions docs/reference/images-and-instances.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
type: reference
audience: developer or operator who works with images and virtual machines through the API
verified: 2026-11-08
verified: 2026-11-11
---

# Images and instances
Expand All @@ -13,10 +13,10 @@ Both live in the namespace `t-<tenant>` of the `phorge.fr` group.
- **Deleting an image** that instances start from is a `409` that names them. Delete them first.
- **Instances**: `cpu` 1 to 16, `memoryMiB` 256 to 65536, `diskGiB` 1 to 500, the rest is what the platform decides (what is not given is not sent). `PATCH` changes `running` (start and stop keep the same VM), `networks`, `cpu`, `memoryMiB`, `diskGiB` and `sshPublicKeys`, applied live. The memory of a **running** instance can only be raised: Incus refuses a lower one (`failed to resize memfd`), so the API answers `409` with the code `running` and the request is not sent, whether it comes by `memoryMiB` or by a profile that comes to less. To lower it, stop the instance, change the memory, then start it again: a change of size never starts or stops an instance by itself, the power state changes only when the request asks for it with `running`. The image, `nesting` and `secureBoot` cannot change: delete and create.
- **The settings of an instance are read as they are in force.** `nesting`, `secureBoot` and `sshPublicKeys` of an instance read through the API are what the VM has, not only what the object says. The `Instance` kind has no default for them: an absent field means the instance did not say, and its profile, or else the default (nesting off, secure boot on, no key), applies. The platform writes the value in force in `status.nesting`, `status.secureBoot` and `status.sshPublicKeys`. The API reads each one from `spec` when the object says it (an instance created before the change has the three stored, written by the old defaults), else from `status`, else from the default, so an instance created without `secureBoot` is shown with `secureBoot: true` before and after the platform stops defaulting it. The field being absent is what counts, never its value: an absent `secureBoot` is not `false`. `spec` comes first because the API writes it (`PATCH` of `sshPublicKeys`) and the status follows a moment later, so the reply to a change shows the new keys; once the status has caught up both are the same, because what the instance says wins over its profile. A request that does not give these fields sends none of them.
- **The quota of the plan is checked by the API first**: a request that would pass it is refused with `409` and the code `quota_exceeded`, before Incus is asked (see [Limits and quotas](limits-and-quotas.md)). Incus stays the authority, and a refusal of its own, such as `Reached maximum number of instances`, comes back as the `problems` of the instance, in words (`This tenant has reached the maximum number of instances of its plan.`), and the instance becomes `Failed` after three minutes. Stopped VMs count. An instance whose first start failed is stuck: delete it and create it again.
- **The limits of the tenant are checked by the API first**: a request that would pass it is refused with `409` and the code `quota_exceeded`, before Incus is asked (see [Limits and quotas](limits-and-quotas.md)). Incus stays the authority, and a refusal of its own, such as `Reached maximum number of instances`, comes back as the `problems` of the instance, in words (`This tenant has reached the maximum number of instances it is allowed.`), and the instance becomes `Failed` after three minutes. Stopped VMs count. An instance whose first start failed is stuck: delete it and create it again.
- **SSH keys are checked strictly.** The composition writes them into the cloud-init of the VM with a plain `printf`, one `- <key>` line per key, indented by two spaces, and nothing else protects it: a line break in a key would add a line of cloud-init, a command run as root in the VM. A key is accepted only as `<type> <base64>` and at most a one word comment of letters, digits and `@._+=/-`.
- **An instance is on one or several networks of its tenant** (`networks`, a list of 1 to 8, see [Networks](networks.md)): named in the request, or the only one of the tenant. `PATCH` replaces the list, live, without a restart. `network` is the deprecated way to give one.
- **The size of an instance is a profile or its own values, never both.** `profile` is one of `GET /v1/tenants/{t}/profiles` (`s` 1 vCPU, 2 GiB, 64 GiB; `m` 2, 4, 128; `l` 4, 8, 256); the other way is `cpu`, `memoryMiB` and `diskGiB`, and what a request leaves out takes 1, 1024 and 10 (the Crossplane kind has no defaults, the API completes the size). A profile with a value is `422`, so is a profile that does not exist, and the answer lists the profiles. The body of an instance carries its `profile` and, in every case, the `cpu`, `memoryMiB` and `diskGiB` it comes to. `GET /v1/limits` has the bounds.
- **A size changes in place**: `PATCH` with a `profile` moves the instance to it and removes its own values; an instance that has a profile leaves it by being given the three values together (a value alone is `422`, it would sit next to the profile). Incus applies it live on a stopped instance.
- **The resources of a plan hold two instances of its own profile size** (`small` two `s`, `medium` two `m`, `large` two `l`), and the count of instances is 2, 4 and 6: an instance that asks for more than what is left is refused with the limit it passes, before Incus is asked (see [Limits and quotas](limits-and-quotas.md)).
- **A user makes their own profiles** (`POST /v1/tenants/{t}/profiles`): CPU, memory and disk, all three given, under a name of 1 to 32 characters (`s`, `m`, `l` and `default` are taken, `422`). They are listed after the three every tenant has, with a phase and what is wrong in words. An instance takes one as it takes `s`, `m` or `l`, and counts in the quota what it comes to. Deleting one is refused (`409`, `in_use`) while an instance has it, and names the instances; `s`, `m` and `l` are not changed nor deleted (`403`). A tenant holds at most `MAX_PROFILES_PER_TENANT` of them. A profile may also say two settings of an instance, `secureBoot` and `sshPublicKeys` (up to 20, checked as the keys of an instance, see the item on SSH keys). They are written on the object only when the request gives them: a profile that does not say one has none, and the body shows none, so an absent `secureBoot` is not `false`. An empty list is the same as none. An instance takes the settings of its profile unless it says its own: keys given by the instance replace the profile's, they do not add to them. A profile never has a network nor `nesting` (Incus refuses nesting on a profile of a tenant project, so nesting stays a setting of the instance): a request with either is `400`, an unknown field. Changing a profile in place is not in the API: make another one and move the instances to it.
- **The resources of every tenant hold two instances of the profile `s`, or one `m`**: 2 instances, 2 vCPU, 4 GiB of memory and 128 GiB of disk, the same for every tenant. An instance that asks for more than what is left is refused with the limit it passes, before Incus is asked (see [Limits and quotas](limits-and-quotas.md)).
- **A user makes their own profiles** (`POST /v1/tenants/{t}/profiles`): CPU, memory and disk, all three given, under a name of 1 to 32 characters (`s`, `m`, `l` and `default` are taken, `422`). They are listed after the three every tenant has, with a phase and what is wrong in words. An instance takes one as it takes `s`, `m` or `l`, and counts in the quota what it comes to. Deleting one is refused (`409`, `in_use`) while an instance has it, and names the instances; `s`, `m` and `l` are not changed nor deleted (`403`). A tenant holds at most 2 of them (the same for every tenant, a third is `409`, `quota_exceeded`, `this tenant has 2 profiles out of 2 allowed (s, m and l do not count): delete one first`). A profile may also say two settings of an instance, `secureBoot` and `sshPublicKeys` (up to 20, checked as the keys of an instance, see the item on SSH keys). They are written on the object only when the request gives them: a profile that does not say one has none, and the body shows none, so an absent `secureBoot` is not `false`. An empty list is the same as none. An instance takes the settings of its profile unless it says its own: keys given by the instance replace the profile's, they do not add to them. A profile never has a network nor `nesting` (Incus refuses nesting on a profile of a tenant project, so nesting stays a setting of the instance): a request with either is `400`, an unknown field. Changing a profile in place is not in the API: make another one and move the instances to it.
Loading
Loading