18772: add support for the AWS EBS autoscale script to the compute node
[arvados.git] / doc / install / crunch2-cloud / install-dispatch-cloud.html.textile.liquid
1 ---
2 layout: default
3 navsection: installguide
4 title: Install the cloud dispatcher
5 ...
6 {% comment %}
7 Copyright (C) The Arvados Authors. All rights reserved.
8
9 SPDX-License-Identifier: CC-BY-SA-3.0
10 {% endcomment %}
11
12 {% include 'notebox_begin_warning' %}
13 @arvados-dispatch-cloud@ is only relevant for cloud installations. Skip this section if you are installing an on premises cluster that will spool jobs to Slurm or LSF.
14 {% include 'notebox_end' %}
15
16 # "Introduction":#introduction
17 # "Create compute node VM image":#create-image
18 # "Update config.yml":#update-config
19 # "Install arvados-dispatch-cloud":#install-packages
20 # "Start the service":#start-service
21 # "Restart the API server and controller":#restart-api
22 # "Confirm working installation":#confirm-working
23
24 h2(#introduction). Introduction
25
26 The cloud dispatch service is for running containers on cloud VMs. It works with Microsoft Azure and Amazon EC2; future versions will also support Google Compute Engine.
27
28 The cloud dispatch service can run on any node that can connect to the Arvados API service, the cloud provider's API, and the SSH service on cloud VMs.  It is not resource-intensive, so you can run it on the API server node.
29
30 More detail about the internal operation of the dispatcher can be found in the "architecture section":{{site.baseurl}}/architecture/dispatchcloud.html.
31
32 h2(#update-config). Update config.yml
33
34 h3. Configure CloudVMs
35
36 Add or update the following portions of your cluster configuration file, @config.yml@. Refer to "config.defaults.yml":{{site.baseurl}}/admin/config.html for information about additional configuration options. The @DispatchPrivateKey@ should be the *private* key generated in "the previous section":install-compute-node.html#sshkeypair.
37
38 <notextile>
39 <pre><code>    Services:
40       DispatchCloud:
41         InternalURLs:
42           "http://localhost:9006": {}
43     Containers:
44       CloudVMs:
45         # BootProbeCommand is a shell command that succeeds when an instance is ready for service
46         BootProbeCommand: "sudo systemctl status docker"
47
48         <b># --- driver-specific configuration goes here --- see Amazon and Azure examples below ---</b>
49
50       DispatchPrivateKey: |
51         -----BEGIN RSA PRIVATE KEY-----
52         MIIEpQIBAAKCAQEAqXoCzcOBkFQ7w4dvXf9B++1ctgZRqEbgRYL3SstuMV4oawks
53         ttUuxJycDdsPmeYcHsKo8vsEZpN6iYsX6ZZzhkO5nEayUTU8sBjmg1ZCTo4QqKXr
54         FJ+amZ7oYMDof6QEdwl6KNDfIddL+NfBCLQTVInOAaNss7GRrxLTuTV7HcRaIUUI
55         jYg0Ibg8ZZTzQxCvFXXnjseTgmOcTv7CuuGdt91OVdoq8czG/w8TwOhymEb7mQlt
56         lXuucwQvYgfoUgcnTgpJr7j+hafp75g2wlPozp8gJ6WQ2yBWcfqL2aw7m7Ll88Nd
57         [...]
58         oFyAjVoexx0RBcH6BveTfQtJKbktP1qBO4mXo2dP0cacuZEtlAqW9Eb06Pvaw/D9
59         foktmqOY8MyctzFgXBpGTxPliGjqo8OkrOyQP2g+FL7v+Km31Xs61P8=
60         -----END RSA PRIVATE KEY-----
61     InstanceTypes:
62       x1md:
63         ProviderType: x1.medium
64         VCPUs: 8
65         RAM: 64GiB
66         IncludedScratch: 64GB
67         Price: 0.62
68       x1lg:
69         ProviderType: x1.large
70         VCPUs: 16
71         RAM: 128GiB
72         IncludedScratch: 128GB
73         Price: 1.23
74 </code></pre>
75 </notextile>
76
77 h4. Minimal configuration example for Amazon EC2
78
79 The <span class="userinput">ImageID</span> value is the compute node image that was built in "the previous section":install-compute-node.html#aws.
80
81 <notextile>
82 <pre><code>    Containers:
83       CloudVMs:
84         ImageID: <span class="userinput">ami-01234567890abcdef</span>
85         Driver: ec2
86         DriverParameters:
87           # If you are not using an IAM role for authentication, specify access
88           # credentials here. Otherwise, omit or set AccessKeyID and
89           # SecretAccessKey to an empty value.
90           AccessKeyID: XXXXXXXXXXXXXXXXXXXX
91           SecretAccessKey: YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
92
93           SecurityGroupIDs:
94           - sg-0123abcd
95           SubnetID: subnet-0123abcd
96           Region: us-east-1
97           EBSVolumeType: gp2
98           AdminUsername: arvados
99 </code></pre>
100 </notextile>
101
102 Example policy for the IAM role used by the cloud dispatcher:
103
104 <notextile>
105 <pre>
106 {
107     "Version": "2012-10-17",
108     "Id": "arvados-dispatch-cloud policy",
109     "Statement": [
110         {
111             "Effect": "Allow",
112             "Action": [
113                 "iam:PassRole",
114                 "ec2:DescribeKeyPairs",
115                 "ec2:ImportKeyPair",
116                 "ec2:RunInstances",
117                 "ec2:DescribeInstances",
118                 "ec2:CreateTags",
119                 "ec2:TerminateInstances"
120             ],
121             "Resource": "*"
122         }
123     ]
124 }
125 </pre>
126 </notextile>
127
128 h4. Minimal configuration example for Azure
129
130 Using managed disks:
131
132 The <span class="userinput">ImageID</span> value is the compute node image that was built in "the previous section":install-compute-node.html#azure.
133
134 <notextile>
135 <pre><code>    Containers:
136       CloudVMs:
137         ImageID: <span class="userinput">"zzzzz-compute-v1597349873"</span>
138         Driver: azure
139         # (azure) managed disks: set MaxConcurrentInstanceCreateOps to 20 to avoid timeouts, cf
140         # https://docs.microsoft.com/en-us/azure/virtual-machines/linux/capture-image
141         MaxConcurrentInstanceCreateOps: 20
142         DriverParameters:
143           # Credentials.
144           SubscriptionID: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
145           ClientID: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
146           ClientSecret: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
147           TenantID: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
148
149           # Data center where VMs will be allocated
150           Location: centralus
151
152           # The resource group where the VM and virtual NIC will be
153           # created.
154           ResourceGroup: zzzzz
155           NetworkResourceGroup: yyyyy   # only if different from ResourceGroup
156           Network: xxxxx
157           Subnet: xxxxx-subnet-private
158
159           # The resource group where the disk image is stored, only needs to
160           # be specified if it is different from ResourceGroup
161           ImageResourceGroup: aaaaa
162
163 </code></pre>
164 </notextile>
165
166 Azure recommends using managed images. If you plan to start more than 20 VMs simultaneously, Azure recommends using a shared image gallery instead to avoid slowdowns and timeouts during the creation of the VMs.
167
168 Using an image from a shared image gallery:
169
170 <notextile>
171 <pre><code>    Containers:
172       CloudVMs:
173         ImageID: <span class="userinput">"shared_image_gallery_image_definition_name"</span>
174         Driver: azure
175         DriverParameters:
176           # Credentials.
177           SubscriptionID: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
178           ClientID: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
179           ClientSecret: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
180           TenantID: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
181
182           # Data center where VMs will be allocated
183           Location: centralus
184
185           # The resource group where the VM and virtual NIC will be
186           # created.
187           ResourceGroup: zzzzz
188           NetworkResourceGroup: yyyyy   # only if different from ResourceGroup
189           Network: xxxxx
190           Subnet: xxxxx-subnet-private
191
192           # The resource group where the disk image is stored, only needs to
193           # be specified if it is different from ResourceGroup
194           ImageResourceGroup: aaaaa
195
196           # (azure) shared image gallery: the name of the gallery
197           SharedImageGalleryName: "shared_image_gallery_1"
198           # (azure) shared image gallery: the version of the image definition
199           SharedImageGalleryImageVersion: "0.0.1"
200
201 </code></pre>
202 </notextile>
203
204 Using unmanaged disks (deprecated):
205
206 The <span class="userinput">ImageID</span> value is the compute node image that was built in "the previous section":install-compute-node.html#azure.
207
208 <notextile>
209 <pre><code>    Containers:
210       CloudVMs:
211         ImageID: <span class="userinput">"https://zzzzzzzz.blob.core.windows.net/system/Microsoft.Compute/Images/images/zzzzz-compute-osDisk.55555555-5555-5555-5555-555555555555.vhd"</span>
212         Driver: azure
213         DriverParameters:
214           # Credentials.
215           SubscriptionID: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
216           ClientID: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
217           ClientSecret: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
218           TenantID: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
219
220           # Data center where VMs will be allocated
221           Location: centralus
222
223           # The resource group where the VM and virtual NIC will be
224           # created.
225           ResourceGroup: zzzzz
226           NetworkResourceGroup: yyyyy   # only if different from ResourceGroup
227           Network: xxxxx
228           Subnet: xxxxx-subnet-private
229
230           # Where to store the VM VHD blobs
231           StorageAccount: example
232           BlobContainer: vhds
233
234 </code></pre>
235 </notextile>
236
237 Get the @SubscriptionID@ and @TenantID@:
238
239 <pre>
240 $ az account list
241 [
242   {
243     "cloudName": "AzureCloud",
244     "id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX",
245     "isDefault": true,
246     "name": "Your Subscription",
247     "state": "Enabled",
248     "tenantId": "YYYYYYYY-YYYY-YYYY-YYYYYYYY",
249     "user": {
250       "name": "you@example.com",
251       "type": "user"
252     }
253   }
254 ]
255 </pre>
256
257 You will need to create a "service principal" to use as a delegated authority for API access.
258
259 <notextile><pre><code>$ az ad app create --display-name "Arvados Dispatch Cloud (<span class="userinput">ClusterID</span>)" --homepage "https://arvados.org" --identifier-uris "https://<span class="userinput">ClusterID.example.com</span>" --end-date 2299-12-31 --password <span class="userinput">Your_Password</span>
260 $ az ad sp create "<span class="userinput">appId</span>"
261 (appId is part of the response of the previous command)
262 $ az role assignment create --assignee "<span class="userinput">objectId</span>" --role Owner --scope /subscriptions/{subscriptionId}/
263 (objectId is part of the response of the previous command)
264 </code></pre></notextile>
265
266 Now update your @config.yml@ file:
267
268 @ClientID@ is the 'appId' value.
269
270 @ClientSecret@ is what was provided as <span class="userinput">Your_Password</span>.
271
272 h3. Test your configuration
273
274 Run the @cloudtest@ tool to verify that your configuration works. This creates a new cloud VM, confirms that it boots correctly and accepts your configured SSH private key, and shuts it down.
275
276 <notextile>
277 <pre><code>~$ <span class="userinput">arvados-server cloudtest && echo "OK!"</span>
278 </code></pre>
279 </notextile>
280
281 Refer to the "cloudtest tool documentation":../../admin/cloudtest.html for more information.
282
283 {% assign arvados_component = 'arvados-dispatch-cloud' %}
284
285 {% include 'install_packages' %}
286
287 {% include 'start_service' %}
288
289 {% include 'restart_api' %}
290
291 h2(#confirm-working). Confirm working installation
292
293 On the dispatch node, start monitoring the arvados-dispatch-cloud logs:
294
295 <notextile>
296 <pre><code>~$ <span class="userinput">sudo journalctl -o cat -fu arvados-dispatch-cloud.service</span>
297 </code></pre>
298 </notextile>
299
300 "Make sure to install the arvados/jobs image.":../install-jobs-image.html
301
302 Submit a simple container request:
303
304 <notextile>
305 <pre><code>shell:~$ <span class="userinput">arv container_request create --container-request '{
306   "name":            "test",
307   "state":           "Committed",
308   "priority":        1,
309   "container_image": "arvados/jobs:latest",
310   "command":         ["echo", "Hello, Crunch!"],
311   "output_path":     "/out",
312   "mounts": {
313     "/out": {
314       "kind":        "tmp",
315       "capacity":    1000
316     }
317   },
318   "runtime_constraints": {
319     "vcpus": 1,
320     "ram": 1048576
321   }
322 }'</span>
323 </code></pre>
324 </notextile>
325
326 This command should return a record with a @container_uuid@ field.  Once @arvados-dispatch-cloud@ polls the API server for new containers to run, you should see it dispatch that same container.
327
328 The @arvados-dispatch-cloud@ API provides a list of queued and running jobs and cloud instances. Use your @ManagementToken@ to test the dispatcher's endpoint. For example, when one container is running:
329
330 <notextile>
331 <pre><code>~$ <span class="userinput">curl -sH "Authorization: Bearer $token" http://localhost:9006/arvados/v1/dispatch/containers</span>
332 {
333   "items": [
334     {
335       "container": {
336         "uuid": "zzzzz-dz642-hdp2vpu9nq14tx0",
337         ...
338         "state": "Running",
339         "scheduling_parameters": {
340           "partitions": null,
341           "preemptible": false,
342           "max_run_time": 0
343         },
344         "exit_code": 0,
345         "runtime_status": null,
346         "started_at": null,
347         "finished_at": null
348       },
349       "instance_type": {
350         "Name": "Standard_D2s_v3",
351         "ProviderType": "Standard_D2s_v3",
352         "VCPUs": 2,
353         "RAM": 8589934592,
354         "Scratch": 16000000000,
355         "IncludedScratch": 16000000000,
356         "AddedScratch": 0,
357         "Price": 0.11,
358         "Preemptible": false
359       }
360     }
361   ]
362 }
363 </code></pre>
364 </notextile>
365
366 A similar request can be made to the @http://localhost:9006/arvados/v1/dispatch/instances@ endpoint.
367
368 When the container finishes, the dispatcher will log it.
369
370 After the container finishes, you can get the container record by UUID *from a shell server* to see its results:
371
372 <notextile>
373 <pre><code>shell:~$ <span class="userinput">arv get <b>zzzzz-dz642-hdp2vpu9nq14tx0</b></span>
374 {
375  ...
376  "exit_code":0,
377  "log":"a01df2f7e5bc1c2ad59c60a837e90dc6+166",
378  "output":"d41d8cd98f00b204e9800998ecf8427e+0",
379  "state":"Complete",
380  ...
381 }
382 </code></pre>
383 </notextile>
384
385 You can use standard Keep tools to view the container's output and logs from their corresponding fields.  For example, to see the logs from the collection referenced in the @log@ field:
386
387 <notextile>
388 <pre><code>~$ <span class="userinput">arv keep ls <b>a01df2f7e5bc1c2ad59c60a837e90dc6+166</b></span>
389 ./crunch-run.txt
390 ./stderr.txt
391 ./stdout.txt
392 ~$ <span class="userinput">arv-get <b>a01df2f7e5bc1c2ad59c60a837e90dc6+166</b>/stdout.txt</span>
393 2016-08-05T13:53:06.201011Z Hello, Crunch!
394 </code></pre>
395 </notextile>
396
397 If the container does not dispatch successfully, refer to the @arvados-dispatch-cloud@ logs for information about why it failed.