You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/admin/templates/extending-templates/prebuilt-workspaces.md
+37-42
Original file line number
Diff line number
Diff line change
@@ -13,6 +13,15 @@ Prebuilt workspaces are:
13
13
- Claimed transparently when developers create workspaces.
14
14
- Monitored and replaced automatically to maintain your desired pool size.
15
15
16
+
## Relationship to workspace presets
17
+
18
+
Prebuilt workspaces are tightly integrated with [workspace presets](./parameters.md#workspace-presets-beta):
19
+
20
+
1. Each prebuilt workspace is associated with a specific template preset.
21
+
1. The preset must define all required parameters needed to build the workspace.
22
+
1. The preset parameters define the base configuration and are immutable once a prebuilt workspace is provisioned.
23
+
1. Parameters that are not defined in the preset can still be customized by users when they claim a workspace.
24
+
16
25
## Prerequisites
17
26
18
27
-[**Premium license**](../../licensing/index.md)
@@ -21,7 +30,7 @@ Prebuilt workspaces are:
21
30
22
31
## Enable prebuilt workspaces for template presets
23
32
24
-
In your template, add a `prebuilds` block within a `coder_workspace_preset`block to identify how many prebuilt
33
+
In your template, add a `prebuilds` block within a `coder_workspace_preset`definition to identify how many prebuilt
25
34
instances your Coder deployment should maintain:
26
35
27
36
```hcl
@@ -38,79 +47,65 @@ instances your Coder deployment should maintain:
38
47
}
39
48
```
40
49
41
-
After you create or update the template, Coder automatically provisions and maintains prebuilt workspaces through an
42
-
internal reconciliation loop (similar to Kubernetes) to maintain the number of specified `instances`.
43
-
44
-
Prebuilt workspaces are displayed in the list of workspaces on the Coder dashboard with the owner set to `prebuilds`.
50
+
After you publish a new template version, Coder will automatically provision and maintain prebuilt workspaces through an
51
+
internal reconciliation loop (similar to Kubernetes) to ensure the defined `instances` count are running.
45
52
46
53
## Prebuilt workspace lifecycle
47
54
48
55
Prebuilt workspaces follow a specific lifecycle from creation through eligibility to claiming.
49
56
50
-
Expand each item in this list for more information about the stage:
57
+
1. After you configure a preset with prebuilds and publish the template, Coder provisions the prebuilt workspace(s).
51
58
52
-
1. <details><summary>After you configure a preset with a prebuilt workspace and publish the template, Coder provisions
53
-
the prebuilt workspace(s).</summary>
54
-
55
-
1. Coder automatically creates prebuilt workspaces up to the specified `instances` count.
56
-
1. Each new prebuild is initially owned by an unprivileged system pseudo-user named `prebuilds`.
59
+
1. Coder automatically creates the defined `instances` count of prebuilt workspaces.
60
+
1. Each new prebuilt workspace is initially owned by an unprivileged system pseudo-user named `prebuilds`.
57
61
- The `prebuilds` user belongs to the `Everyone` group (you can add it to additional groups if needed).
58
62
1. Each prebuilt workspace receives a randomly generated name for identification.
59
-
1. The workspace is provisioned like a regular workspace.
60
-
61
-
</details>
63
+
1. The workspace is provisioned like a regular workspace; only its ownership distinguishes it as a prebuilt workspace.
62
64
63
-
1.<details><summary>Coder prepares the prebuilt workspace to be claimed by a developer.</summary>
65
+
1.Prebuilt workspaces start up and become eligible to be claimed by a developer.
64
66
65
67
Before a prebuilt workspace is available to users:
66
68
67
-
1. The workspace reaches `running` state.
68
-
1. The agent connects to coderd.
69
-
1. The agent starts its bootstrap procedures and startup scripts complete successfully.
69
+
1. The workspace is provisioned.
70
+
1. The agent starts up and connects to coderd.
71
+
1. The agent starts its bootstrap procedures and completes its startup scripts.
70
72
1. The agent reports `ready` status.
71
73
72
-
Prebuilt workspaces that fail during provisioning are retried with an exponential backoff to prevent transient failures.
74
+
Only once the agent reports `ready` is the prebuilt workspace considered eligible.
73
75
74
-
</details>
76
+
Prebuilt workspaces that fail during provisioning are retried with a backoff to prevent transient failures.
75
77
76
-
1.<details><summary>When a developer selects requests a new workspace, the claiming process occurs:</summary>
78
+
1. When a developer requests a new workspace, the claiming process occurs:
77
79
78
80
1. Developer selects a template and preset that has prebuilt workspaces configured.
79
-
1. If an eligible prebuilt workspace exists, it's automatically assigned to the user.
80
-
1. Ownership transfers from the `prebuilds` user to the requesting user.
81
+
1. If an eligible prebuilt workspace exists, ownership transfers from the `prebuilds` user to the requesting user.
81
82
1. The workspace name changes to the user's requested name.
82
-
1. The process is transparent to the developer - they simply see a workspace ready faster than normal.
83
+
1.`terraform apply` is executed using the new ownership details, which may affect the [`coder_workspace`](https://registry.terraform.io/providers/coder/coder/latest/docs/data-sources/workspace) and
datasources (see [Preventing resource replacement](#preventing-resource-replacement) for further considerations).
83
86
84
-
This ownership transfer happens automatically without any special action required by the user.
85
-
86
-
</details>
87
+
The process is transparent to the developer - they simply see a workspace ready faster than normal.
87
88
88
89
You can view available prebuilt workspaces in the **Workspaces** view in the Coder dashboard:
89
90
90
91

91
92
93
+
_Note the search term `owner:prebuilds`._
94
+
92
95
### Template updates and the prebuilt workspace lifecycle
93
96
94
-
Prebuilt workspaces have specific behavior when templates are updated:
97
+
Prebuilt workspaces are not updated after they are provisioned.
98
+
99
+
When a template's active version is updated:
95
100
96
-
1.When a template version changes, prebuilt workspaces for old versions are automatically deleted.
101
+
1.Prebuilt workspaces for old versions are automatically deleted.
97
102
1. New prebuilt workspaces are created for the active template version.
98
-
1. Prebuilt workspaces aren't automatically updated after creation.
99
-
1. If dependencies change (e.g., an [AMI](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AMIs.html) update) without a template version change, you can:
100
-
- Delete the existing prebuilt workspaces manually.
103
+
1. If dependencies change (e.g., an [AMI](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AMIs.html) update) without a template version change:
104
+
- You may delete the existing prebuilt workspaces manually.
101
105
- Coder will automatically create new prebuilt workspaces with the updated dependencies.
102
106
103
107
The system always maintains the desired number of prebuilt workspaces for the active template version.
104
108
105
-
### Relationship to workspace presets
106
-
107
-
Prebuilt workspaces are tightly integrated with [workspace presets](./parameters.md#workspace-presets-beta):
108
-
109
-
1. Each prebuilt workspace is associated with a specific template preset.
110
-
1. The preset must define all required parameters needed to build the workspace.
111
-
1. The preset parameters define the base configuration and are immutable after they're claimed.
112
-
1. Parameters that are not defined in the preset can still be customized by users when they claim a workspace.
113
-
114
109
## Administration and troubleshooting
115
110
116
111
### Managing resource quotas
@@ -129,7 +124,7 @@ If a quota is exceeded, the prebuilt workspace will fail provisioning the same w
129
124
130
125
When a prebuilt workspace is claimed, another `terraform apply` run occurs with new values for the workspace owner and name.
131
126
132
-
This can cause issues:
127
+
This can cause issues in the following scenario:
133
128
134
129
1. The workspace is initially created with values from the `prebuilds` user and a random name.
135
130
1. After claiming, various workspace properties change (ownership, name, and potentially other values), which Terraform sees as configuration drift.
0 commit comments