mirror of
https://github.com/coder/coder.git
synced 2025-07-09 11:45:56 +00:00
Refactored Quota Docs (#5195)
This commit is contained in:
@ -1,21 +1,19 @@
|
|||||||
# Quotas
|
# Quotas
|
||||||
|
|
||||||
Coder Enterprise admins may define quotas to control costs
|
Quotas are a mechanism for controlling spend by associating costs with workspace
|
||||||
and ensure equitable access to cloud resources. The quota system controls
|
templates and assigning budgets to users. Users that exceed their budget will be
|
||||||
instantaneous cost. For example, the system can ensure that every user in your
|
blocked from launching more workspaces until they either delete their other workspaces
|
||||||
deployment has a spend rate lower than $10/day at any given moment.
|
or get their budget extended.
|
||||||
|
|
||||||
The workspace provisioner enforces quota during workspace start and stop operations.
|
For example: A template is configured with a cost of 5 credits per day, and the user is
|
||||||
When users reach their quota, they may unblock themselves by stopping or deleting
|
granted a budget of 15 credits per day. This budget limits the user to 3 concurrent workspaces.
|
||||||
their workspace(s).
|
|
||||||
|
|
||||||
Quotas are licensed with [Groups](./groups.md).
|
Quotas are licensed with [Groups](./groups.md).
|
||||||
|
|
||||||
## Definitions
|
## Definitions
|
||||||
|
|
||||||
- **Credits** is the fundamental unit of the quota system. They map to the
|
- **Credits** is the fundamental unit representing cost in the quota system. This integer
|
||||||
smallest denomination of your preferred currency. For example, if you work with USD,
|
can be arbitrary, or it can map to your preferred currency.
|
||||||
think of each credit as a cent.
|
|
||||||
- **Budget** is the per-user, enforced, upper limit to credit spend.
|
- **Budget** is the per-user, enforced, upper limit to credit spend.
|
||||||
- **Allowance** is a grant of credits to the budget.
|
- **Allowance** is a grant of credits to the budget.
|
||||||
|
|
||||||
@ -29,18 +27,13 @@ less quota than an online workspace.
|
|||||||
A common use case is separating costs for a persistent volume and ephemeral compute:
|
A common use case is separating costs for a persistent volume and ephemeral compute:
|
||||||
|
|
||||||
```hcl
|
```hcl
|
||||||
resource "coder_metadata" "volume" {
|
|
||||||
resource_id = "${docker_volume.home_volume.id}"
|
|
||||||
cost = 10
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "docker_volume" "home_volume" {
|
resource "docker_volume" "home_volume" {
|
||||||
name = "coder-${data.coder_workspace.me.owner}-${data.coder_workspace.me.name}-root"
|
name = "coder-${data.coder_workspace.me.owner}-${data.coder_workspace.me.name}-root"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "coder_metadata" "container" {
|
resource "coder_metadata" "home_volume" {
|
||||||
resource_id = "${docker_container.workspace.id}"
|
resource_id = docker_volume.home_volume.id
|
||||||
cost = 20
|
daily_cost = 10
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "docker_container" "workspace" {
|
resource "docker_container" "workspace" {
|
||||||
@ -53,10 +46,22 @@ resource "docker_container" "workspace" {
|
|||||||
read_only = false
|
read_only = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resource "coder_metadata" "workspace" {
|
||||||
|
count = data.coder_workspace.me.start_count
|
||||||
|
resource_id = docker_container.workspace.id
|
||||||
|
daily_cost = 20
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
In that template, the workspace consumes 10 quota credits when it's offline, and
|
When the workspace above is shut down, the `docker_container` and
|
||||||
30 when it's online.
|
`coder_metadata` both get deleted. This reduces the cost from 30 credits to
|
||||||
|
10 credits.
|
||||||
|
|
||||||
|
Resources without a `daily_cost` value are considered to cost 0. If the cost
|
||||||
|
was removed on the `docker_volume` above, the template would consume 0 credits when
|
||||||
|
it's offline. This technique is good for incentivizing users to shut down their
|
||||||
|
unused workspaces and freeing up compute in the cluster.
|
||||||
|
|
||||||
## Establishing Budgets
|
## Establishing Budgets
|
||||||
|
|
||||||
@ -69,18 +74,20 @@ For example:
|
|||||||
|
|
||||||
| Group Name | Quota Allowance |
|
| Group Name | Quota Allowance |
|
||||||
| ---------- | --------------- |
|
| ---------- | --------------- |
|
||||||
| Frontend | 100 |
|
| Frontend | 10 |
|
||||||
| Backend | 200 |
|
| Backend | 20 |
|
||||||
| Data | 300 |
|
| Data | 30 |
|
||||||
|
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
| Username | Groups | Effective Budget |
|
| Username | Groups | Effective Budget |
|
||||||
| -------- | ----------------- | ---------------- |
|
| -------- | ----------------- | ---------------- |
|
||||||
| jill | Frontend, Backend | 300 |
|
| jill | Frontend, Backend | 30 |
|
||||||
| jack | Backend, Data | 500 |
|
| jack | Backend, Data | 50 |
|
||||||
| sam | Data | 300 |
|
| sam | Data | 30 |
|
||||||
| alex | Frontend | 100 |
|
| alex | Frontend | 10 |
|
||||||
|
|
||||||
|
By default, groups are assumed to have a default allowance of 0.
|
||||||
|
|
||||||
## Quota Enforcement
|
## Quota Enforcement
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user