1
1
# Quotas
2
2
3
- Coder Enterprise admins may define quotas to control costs
4
- and ensure equitable access to cloud resources. The quota system controls
5
- instantaneous cost. For example, the system can ensure that every user in your
6
- deployment has a spend rate lower than $10/day at any given moment .
3
+ Quotas are a mechanism for controlling spend by associating costs with workspace
4
+ templates and assigning budgets to users. Users that exceed their budget will be
5
+ blocked from launching more workspaces until they either delete their other workspaces
6
+ or get their budget extended .
7
7
8
- The workspace provisioner enforces quota during workspace start and stop operations.
9
- When users reach their quota, they may unblock themselves by stopping or deleting
10
- their workspace(s).
8
+ For example: A template is configured with a cost of 5 credits per day, and the user is
9
+ granted a budget of 15 credits per day. This budget limits the user to 3 concurrent workspaces.
11
10
12
11
Quotas are licensed with [ Groups] ( ./groups.md ) .
13
12
14
13
## Definitions
15
14
16
- - ** Credits** is the fundamental unit of the quota system. They map to the
17
- smallest denomination of your preferred currency. For example, if you work with USD,
18
- think of each credit as a cent.
15
+ - ** Credits** is the fundamental unit representing cost in the quota system. This integer
16
+ can be arbitrary, or it can map to your preferred currency.
19
17
- ** Budget** is the per-user, enforced, upper limit to credit spend.
20
18
- ** Allowance** is a grant of credits to the budget.
21
19
@@ -29,18 +27,13 @@ less quota than an online workspace.
29
27
A common use case is separating costs for a persistent volume and ephemeral compute:
30
28
31
29
``` hcl
32
- resource "coder_metadata" "volume" {
33
- resource_id = "${docker_volume.home_volume.id}"
34
- cost = 10
35
- }
36
-
37
30
resource "docker_volume" "home_volume" {
38
31
name = "coder-${data.coder_workspace.me.owner}-${data.coder_workspace.me.name}-root"
39
32
}
40
33
41
- resource "coder_metadata" "container " {
42
- resource_id = "${docker_container.workspace .id}"
43
- cost = 20
34
+ resource "coder_metadata" "home_volume " {
35
+ resource_id = docker_volume.home_volume .id
36
+ daily_cost = 10
44
37
}
45
38
46
39
resource "docker_container" "workspace" {
@@ -53,10 +46,22 @@ resource "docker_container" "workspace" {
53
46
read_only = false
54
47
}
55
48
}
49
+
50
+ resource "coder_metadata" "workspace" {
51
+ count = data.coder_workspace.me.start_count
52
+ resource_id = docker_container.workspace.id
53
+ daily_cost = 20
54
+ }
56
55
```
57
56
58
- In that template, the workspace consumes 10 quota credits when it's offline, and
59
- 30 when it's online.
57
+ When the workspace above is shut down, the ` docker_container ` and
58
+ ` coder_metadata ` both get deleted. This reduces the cost from 30 credits to
59
+ 10 credits.
60
+
61
+ Resources without a ` daily_cost ` value are considered to cost 0. If the cost
62
+ was removed on the ` docker_volume ` above, the template would consume 0 credits when
63
+ it's offline. This technique is good for incentivizing users to shut down their
64
+ unused workspaces and freeing up compute in the cluster.
60
65
61
66
## Establishing Budgets
62
67
@@ -69,18 +74,20 @@ For example:
69
74
70
75
| Group Name | Quota Allowance |
71
76
| ---------- | --------------- |
72
- | Frontend | 100 |
73
- | Backend | 200 |
74
- | Data | 300 |
77
+ | Frontend | 10 |
78
+ | Backend | 20 |
79
+ | Data | 30 |
75
80
76
81
<br />
77
82
78
83
| Username | Groups | Effective Budget |
79
84
| -------- | ----------------- | ---------------- |
80
- | jill | Frontend, Backend | 300 |
81
- | jack | Backend, Data | 500 |
82
- | sam | Data | 300 |
83
- | alex | Frontend | 100 |
85
+ | jill | Frontend, Backend | 30 |
86
+ | jack | Backend, Data | 50 |
87
+ | sam | Data | 30 |
88
+ | alex | Frontend | 10 |
89
+
90
+ By default, groups are assumed to have a default allowance of 0.
84
91
85
92
## Quota Enforcement
86
93
0 commit comments