1
- # Provisioners
1
+ # External provisioners
2
2
3
3
By default, the Coder server runs
4
4
[ built-in provisioner daemons] ( ../reference/cli/server.md#provisioner-daemons ) ,
5
5
which execute ` terraform ` during workspace and template builds. However, there
6
- are sometimes benefits to running external provisioner daemons:
6
+ are often benefits to running external provisioner daemons:
7
7
8
8
- ** Secure build environments:** Run build jobs in isolated containers,
9
- preventing malicious templates from gaining shell access to the Coder host.
9
+ preventing malicious templates from gaining sh access to the Coder host.
10
10
11
11
- ** Isolate APIs:** Deploy provisioners in isolated environments (on-prem, AWS,
12
12
Azure) instead of exposing APIs (Docker, Kubernetes, VMware) to the Coder
13
- server. See [ Provider Authentication] ( ../admin/external-auth.md ) for more
14
- details.
13
+ server. See
14
+ [ Provider Authentication] ( ../admin/templates/extending-templates/provider-authentication.md )
15
+ for more details.
15
16
16
17
- ** Isolate secrets** : Keep Coder unaware of cloud secrets, manage/rotate
17
18
secrets on provisioner servers.
18
19
19
20
- ** Reduce server load** : External provisioners reduce load and build queue
20
21
times from the Coder server. See
21
- [ Scaling Coder] ( ../admin/infrastructure/scale-utility .md#recent- scale-tests )
22
- for more details.
22
+ [ Scaling Coder] ( ../admin/infrastructure/README .md#scale-tests ) for more
23
+ details.
23
24
24
- Each provisioner can run a single
25
+ Each provisioner runs a single
25
26
[ concurrent workspace build] ( ../admin/infrastructure/scale-testing.md#control-plane-provisionerd ) .
26
27
For example, running 30 provisioner containers will allow 30 users to start
27
28
workspaces at the same time.
28
29
29
30
Provisioners are started with the
30
-
31
- [ coder provisionerd start] ( ../reference/cli/provisioner_start.md ) command.
31
+ [ ` coder provisioner start ` ] ( ../reference/cli/provisioner_start.md ) command in
32
+ the [ full Coder binary] ( https://github.com/coder/coder/releases ) . Keep reading
33
+ to learn how to start provisioners via Docker, Kubernetes, Systemd, etc.
32
34
33
35
## Authentication
34
36
35
37
The provisioner daemon must authenticate with your Coder deployment.
36
38
37
- Set a
38
- [ provisioner daemon pre-shared key (PSK)] ( ../reference/cli/server.md#--provisioner-daemon-psk )
39
- on the Coder server and start the provisioner with
40
- ` coder provisionerd start --psk <your-psk> ` . If you are
41
- [ installing with Helm] ( ../install/kubernetes.md#install-coder-with-helm ) , see
42
- the [ Helm example] ( #example-running-an-external-provisioner-with-helm ) below.
39
+ <div class =" tabs " >
43
40
44
- > Coder still supports authenticating the provisioner daemon with a
45
- > [ token] ( ../reference/cli/tokens.md ) from a user with the Template Admin or
46
- > Owner role. This method is deprecated in favor of the PSK, which only has
47
- > permission to access provisioner daemon APIs. We recommend migrating to the
48
- > PSK as soon as practical.
41
+ ## Scoped Key (Recommended)
49
42
50
- ## Types of provisioners
43
+ We recommend creating finely-scoped keys for provisioners. Keys are scoped to an
44
+ organization.
51
45
52
- Provisioners can broadly be categorized by scope: ` organization ` or ` user ` . The
53
- scope of a provisioner can be specified with
54
- [ ` -tag=scope=<scope> ` ] ( ../reference/cli/provisioner_start.md#t---tag ) when
55
- starting the provisioner daemon. Only users with at least the
56
- [ Template Admin] ( ../admin/users/groups-roles.md#roles ) role or higher may create
57
- organization-scoped provisioner daemons.
46
+ ``` sh
47
+ coder provisioner keys create my-key \
48
+ --org default
58
49
59
- There are two exceptions:
50
+ Successfully created provisioner key my-key ! Save this authentication token, it will not be shown again.
60
51
61
- - [ Built-in provisioners] ( ../reference/cli/server.md#provisioner-daemons ) are
62
- always organization-scoped.
63
- - External provisioners started using a
64
- [ pre-shared key (PSK)] ( ../reference/cli/provisioner_start.md#psk ) are always
65
- organization-scoped.
52
+ < key omitted>
53
+ ```
66
54
67
- ### Organization-Scoped Provisioners
55
+ Or, restrict the provisioner to jobs with specific tags
68
56
69
- ** Organization-scoped Provisioners** can pick up build jobs created by any user.
70
- These provisioners always have the implicit tags ` scope=organization owner="" ` .
57
+ ``` sh
58
+ coder provisioner keys create kubernetes-key \
59
+ --org default \
60
+ --tag environment=kubernetes
61
+
62
+ Successfully created provisioner key kubernetes-key! Save this authentication token, it will not be shown again.
71
63
72
- ``` shell
73
- coder provisionerd start
64
+ < key omitted>
74
65
```
75
66
76
- ### User-scoped Provisioners
67
+ To start the provisioner:
77
68
78
- ** User-scoped Provisioners** can only pick up build jobs created from
79
- user-tagged templates. Unlike the other provisioner types, any Coder user can
80
- run user provisioners, but they have no impact unless there exists at least one
81
- template with the ` scope=user ` provisioner tag.
69
+ ``` sh
70
+ export CODER_URL=https://< your-coder-url>
71
+ export CODER_PROVISIONER_DAEMON_KEY=< key>
72
+ coder provisioner start
73
+ ```
82
74
83
- ``` shell
84
- coder provisionerd start \
85
- --tag scope=user
75
+ Keep reading to see instructions for running provisioners on
76
+ Kubernetes/Docker/etc.
86
77
87
- # In another terminal, create/push
88
- # a template that requires user provisioners
89
- coder templates push on-prem \
90
- --provisioner-tag scope=user
78
+ ## User Tokens
79
+
80
+ A user account with the role ` Template Admin ` or ` Owner ` can start provisioners
81
+ using their user account. This may be beneficial if you are running provisioners
82
+ via [ automation] ( ../reference/README.md ) .
83
+
84
+ ``` sh
85
+ coder login https://< your-coder-url>
86
+ coder provisioner start
87
+ ```
88
+
89
+ To start a provisioner with specific tags:
90
+
91
+ ``` sh
92
+ coder login https://< your-coder-url>
93
+ coder provisioner start \
94
+ --tag environment=kubernetes
91
95
```
92
96
93
- ### Provisioner Tags
97
+ Note: Any user can start [ user-scoped provisioners] ( #User-scoped-Provisioners ) ,
98
+ but this will also require a template on your deployment with the corresponding
99
+ tags.
100
+
101
+ ## Global PSK
102
+
103
+ A deployment-wide PSK can be used to authenticate any provisioner. We do not
104
+ recommend this approach anymore, as it makes key rotation or isolating
105
+ provisioners far more difficult. To use a global PSK, set a
106
+ [ provisioner daemon pre-shared key (PSK)] ( ../reference/cli/server.md#--provisioner-daemon-psk )
107
+ on the Coder server.
108
+
109
+ Next, start the provisioner:
110
+
111
+ ``` sh
112
+ coder provisioner start --psk < your-psk>
113
+ ```
114
+
115
+ </div >
116
+
117
+ ## Provisioner Tags
94
118
95
119
You can use ** provisioner tags** to control which provisioners can pick up build
96
120
jobs from templates (and corresponding workspaces) with matching explicit tags.
@@ -105,10 +129,10 @@ automatically.
105
129
106
130
For example:
107
131
108
- ``` shell
132
+ ``` sh
109
133
# Start a provisioner with the explicit tags
110
134
# environment=on_prem and datacenter=chicago
111
- coder provisionerd start \
135
+ coder provisioner start \
112
136
--tag environment=on_prem \
113
137
--tag datacenter=chicago
114
138
@@ -124,6 +148,10 @@ coder templates push on-prem-chicago \
124
148
--provisioner-tag datacenter=chicago
125
149
```
126
150
151
+ Alternatively, a template can target a provisioner via
152
+ [ workspace tags] ( https://github.com/coder/coder/tree/main/examples/workspace-tags )
153
+ inside the Terraform.
154
+
127
155
A provisioner can run a given build job if one of the below is true:
128
156
129
157
1 . A job with no explicit tags can only be run on a provisioner with no explicit
@@ -171,9 +199,59 @@ This is illustrated in the below table:
171
199
> copy the output:
172
200
>
173
201
> ```
174
- > go test -v -count=1 ./coderd/provisionerdserver / -test.run='^TestAcquirer_MatchTags/GenTable$'
202
+ > go test -v -count=1 ./coderd/provisionerserver / -test.run='^TestAcquirer_MatchTags/GenTable$'
175
203
> ```
176
204
205
+ ## Types of provisioners
206
+
207
+ Provisioners can broadly be categorized by scope: `organization` or `user`. The
208
+ scope of a provisioner can be specified with
209
+ [`-tag=scope=<scope>`](../reference/cli/provisioner_start.md#t---tag) when
210
+ starting the provisioner daemon. Only users with at least the
211
+ [Template Admin](./users/README.md#roles) role or higher may create
212
+ organization-scoped provisioner daemons.
213
+
214
+ There are two exceptions:
215
+
216
+ - [Built-in provisioners](../reference/cli/server.md#provisioner-daemons) are
217
+ always organization-scoped.
218
+ - External provisioners started using a
219
+ [pre-shared key (PSK)](../reference/cli/provisioner_start.md#psk) are always
220
+ organization-scoped.
221
+
222
+ ### Organization-Scoped Provisioners
223
+
224
+ **Organization-scoped Provisioners** can pick up build jobs created by any user.
225
+ These provisioners always have the implicit tags `scope=organization owner=""`.
226
+
227
+ ```sh
228
+ coder provisioner start --org <organization_name>
229
+ ```
230
+
231
+ If you omit the ` --org ` argument, the provisioner will be assigned to the
232
+ default organization.
233
+
234
+ ``` sh
235
+ coder provisioner start
236
+ ```
237
+
238
+ ### User-scoped Provisioners
239
+
240
+ ** User-scoped Provisioners** can only pick up build jobs created from
241
+ user-tagged templates. Unlike the other provisioner types, any Coder user can
242
+ run user provisioners, but they have no impact unless there exists at least one
243
+ template with the ` scope=user ` provisioner tag.
244
+
245
+ ``` sh
246
+ coder provisioner start \
247
+ --tag scope=user
248
+
249
+ # In another terminal, create/push
250
+ # a template that requires user provisioners
251
+ coder templates push on-prem \
252
+ --provisioner-tag scope=user
253
+ ```
254
+
177
255
## Example: Running an external provisioner with Helm
178
256
179
257
Coder provides a Helm chart for running external provisioner daemons, which you
@@ -182,21 +260,21 @@ will use in concert with the Helm chart for deploying the Coder server.
182
260
1 . Create a long, random pre-shared key (PSK) and store it in a Kubernetes
183
261
secret
184
262
185
- ```shell
263
+ ``` sh
186
264
kubectl create secret generic coder-provisioner-psk --from-literal=psk=` head /dev/urandom | base64 | tr -dc A-Za-z0-9 | head -c 26`
187
265
```
188
266
189
267
1 . Modify your Coder ` values.yaml ` to include
190
268
191
269
``` yaml
192
- provisionerDaemon :
270
+ provisioneraemon :
193
271
pskSecretName : " coder-provisioner-psk"
194
272
` ` `
195
273
196
274
1. Redeploy Coder with the new ` values.yaml` to roll out the PSK. You can omit
197
275
` --version <your version>` to also upgrade Coder to the latest version.
198
276
199
- ` ` ` shell
277
+ ` ` ` sh
200
278
helm upgrade coder coder-v2/coder \
201
279
--namespace coder \
202
280
--version <your version> \
@@ -212,7 +290,7 @@ will use in concert with the Helm chart for deploying the Coder server.
212
290
- name: CODER_URL
213
291
value: "https://coder.example.com"
214
292
replicaCount: 10
215
- provisionerDaemon :
293
+ provisioneraemon :
216
294
pskSecretName: "coder-provisioner-psk"
217
295
tags:
218
296
location: auh
@@ -230,7 +308,7 @@ will use in concert with the Helm chart for deploying the Coder server.
230
308
231
309
1. Install the provisioner daemon chart
232
310
233
- ` ` ` shell
311
+ ` ` ` sh
234
312
helm install coder-provisioner coder-v2/coder-provisioner \
235
313
--namespace coder \
236
314
--version <your version> \
@@ -239,35 +317,35 @@ will use in concert with the Helm chart for deploying the Coder server.
239
317
240
318
You can verify that your provisioner daemons have successfully connected to
241
319
Coderd by looking for a debug log message that says
242
- `provisionerd : successfully connected to coderd` from each Pod.
320
+ `provisioner : successfully connected to coderd` from each Pod.
243
321
244
322
# # Example: Running an external provisioner on a VM
245
323
246
- ` ` ` shell
324
+ ` ` ` sh
247
325
curl -L https://coder.com/install.sh | sh
248
326
export CODER_URL=https://coder.example.com
249
327
export CODER_SESSION_TOKEN=your_token
250
- coder provisionerd start
328
+ coder provisioner start
251
329
` ` `
252
330
253
331
# # Example: Running an external provisioner via Docker
254
332
255
- ` ` ` shell
333
+ ` ` ` sh
256
334
docker run --rm -it \
257
335
-e CODER_URL=https://coder.example.com/ \
258
336
-e CODER_SESSION_TOKEN=your_token \
259
337
--entrypoint /opt/coder \
260
338
ghcr.io/coder/coder:latest \
261
- provisionerd start
339
+ provisioner start
262
340
` ` `
263
341
264
342
# # Disable built-in provisioners
265
343
266
344
As mentioned above, the Coder server will run built-in provisioners by default.
267
345
This can be disabled with a server-wide
268
- [flag or environment variable](../reference/cli/server.md#-- provisioner-daemons).
346
+ [flag or environment variable](../reference/cli/server.md#provisioner-daemons).
269
347
270
- ` ` ` shell
348
+ ` ` ` sh
271
349
coder server --provisioner-daemons=0
272
350
` ` `
273
351
0 commit comments