github.com/iqoqo/nomad@v0.11.3-0.20200911112621-d7021c74d101/website/pages/api-docs/deployments.mdx (about) 1 --- 2 layout: api 3 page_title: Deployments - HTTP API 4 sidebar_title: Deployments 5 description: The /deployment endpoints are used to query for and interact with deployments. 6 --- 7 8 # Deployments HTTP API 9 10 The `/deployment` endpoints are used to query for and interact with deployments. 11 12 ## List Deployments 13 14 This endpoint lists all deployments. 15 16 | Method | Path | Produces | 17 | ------ | ----------------- | ------------------ | 18 | `GET` | `/v1/deployments` | `application/json` | 19 20 The table below shows this endpoint's support for 21 [blocking queries](/api-docs#blocking-queries) and 22 [required ACLs](/api-docs#acls). 23 24 | Blocking Queries | ACL Required | 25 | ---------------- | -------------------- | 26 | `YES` | `namespace:read-job` | 27 28 ### Parameters 29 30 - `prefix` `(string: "")`- Specifies a string to filter deployments based on 31 an ID prefix. Because the value is decoded to bytes, the prefix must have an 32 even number of hexadecimal characters (0-9a-f) .This is specified as a query 33 string parameter. 34 35 ### Sample Request 36 37 ```shell-session 38 $ curl \ 39 https://localhost:4646/v1/deployments 40 ``` 41 42 ```shell-session 43 $ curl \ 44 https://localhost:4646/v1/deployments?prefix=25ba81c 45 ``` 46 47 ### Sample Response 48 49 ```json 50 [ 51 { 52 "ID": "70638f62-5c19-193e-30d6-f9d6e689ab8e", 53 "JobID": "example", 54 "JobVersion": 1, 55 "JobModifyIndex": 17, 56 "JobSpecModifyIndex": 17, 57 "JobCreateIndex": 7, 58 "TaskGroups": { 59 "cache": { 60 "Promoted": false, 61 "DesiredCanaries": 1, 62 "DesiredTotal": 3, 63 "PlacedAllocs": 1, 64 "HealthyAllocs": 0, 65 "UnhealthyAllocs": 0 66 } 67 }, 68 "Status": "running", 69 "StatusDescription": "", 70 "CreateIndex": 19, 71 "ModifyIndex": 19 72 } 73 ] 74 ``` 75 76 ## Read Deployment 77 78 This endpoint reads information about a specific deployment by ID. 79 80 | Method | Path | Produces | 81 | ------ | ------------------------------- | ------------------ | 82 | `GET` | `/v1/deployment/:deployment_id` | `application/json` | 83 84 The table below shows this endpoint's support for 85 [blocking queries](/api-docs#blocking-queries) and 86 [required ACLs](/api-docs#acls). 87 88 | Blocking Queries | ACL Required | 89 | ---------------- | -------------------- | 90 | `YES` | `namespace:read-job` | 91 92 ### Parameters 93 94 - `:deployment_id` `(string: <required>)`- Specifies the UUID of the deployment. 95 This must be the full UUID, not the short 8-character one. This is specified 96 as part of the path. 97 98 ### Sample Request 99 100 ```shell-session 101 $ curl \ 102 https://localhost:4646/v1/deployment/70638f62-5c19-193e-30d6-f9d6e689ab8e 103 ``` 104 105 ### Sample Response 106 107 ```json 108 { 109 "ID": "70638f62-5c19-193e-30d6-f9d6e689ab8e", 110 "JobID": "example", 111 "JobVersion": 1, 112 "JobModifyIndex": 17, 113 "JobSpecModifyIndex": 17, 114 "JobCreateIndex": 7, 115 "TaskGroups": { 116 "cache": { 117 "Promoted": false, 118 "DesiredCanaries": 1, 119 "DesiredTotal": 3, 120 "PlacedAllocs": 1, 121 "HealthyAllocs": 0, 122 "UnhealthyAllocs": 0 123 } 124 }, 125 "Status": "running", 126 "StatusDescription": "", 127 "CreateIndex": 19, 128 "ModifyIndex": 19 129 } 130 ``` 131 132 ## List Allocations for Deployment 133 134 This endpoint lists the allocations created or modified for the given 135 deployment. 136 137 | Method | Path | Produces | 138 | ------ | ------------------------------------------- | ------------------ | 139 | `GET` | `/v1/deployment/allocations/:deployment_id` | `application/json` | 140 141 The table below shows this endpoint's support for 142 [blocking queries](/api-docs#blocking-queries) and 143 [required ACLs](/api-docs#acls). 144 145 | Blocking Queries | ACL Required | 146 | ---------------- | -------------------- | 147 | `YES` | `namespace:read-job` | 148 149 ### Parameters 150 151 - `:deployment_id` `(string: <required>)`- Specifies the UUID of the deployment. 152 This must be the full UUID, not the short 8-character one. This is specified 153 as part of the path. 154 155 ### Sample Request 156 157 ```shell-session 158 $ curl \ 159 https://localhost:4646/v1/deployment/allocations/5456bd7a-9fc0-c0dd-6131-cbee77f57577 160 ``` 161 162 ### Sample Response 163 164 ```json 165 [ 166 { 167 "ID": "287b65cc-6c25-cea9-0332-e4a75ca2af98", 168 "EvalID": "9751cb74-1a0d-190e-d026-ad2bc666ad2c", 169 "Name": "example.cache[0]", 170 "NodeID": "cb1f6030-a220-4f92-57dc-7baaabdc3823", 171 "JobID": "example", 172 "TaskGroup": "cache", 173 "DesiredStatus": "run", 174 "DesiredDescription": "", 175 "ClientStatus": "running", 176 "ClientDescription": "", 177 "TaskStates": { 178 "redis": { 179 "State": "running", 180 "Failed": false, 181 "StartedAt": "2017-06-29T22:29:41.52000268Z", 182 "FinishedAt": "0001-01-01T00:00:00Z", 183 "Events": [ 184 { 185 "Type": "Received", 186 "Time": 1498775380693307400, 187 "FailsTask": false, 188 "RestartReason": "", 189 "SetupError": "", 190 "DriverError": "", 191 "ExitCode": 0, 192 "Signal": 0, 193 "Message": "", 194 "KillTimeout": 0, 195 "KillError": "", 196 "KillReason": "", 197 "StartDelay": 0, 198 "DownloadError": "", 199 "ValidationError": "", 200 "DiskLimit": 0, 201 "FailedSibling": "", 202 "VaultError": "", 203 "TaskSignalReason": "", 204 "TaskSignal": "", 205 "DriverMessage": "" 206 }, 207 { 208 "Type": "Task Setup", 209 "Time": 1498775380693659000, 210 "FailsTask": false, 211 "RestartReason": "", 212 "SetupError": "", 213 "DriverError": "", 214 "ExitCode": 0, 215 "Signal": 0, 216 "Message": "Building Task Directory", 217 "KillTimeout": 0, 218 "KillError": "", 219 "KillReason": "", 220 "StartDelay": 0, 221 "DownloadError": "", 222 "ValidationError": "", 223 "DiskLimit": 0, 224 "FailedSibling": "", 225 "VaultError": "", 226 "TaskSignalReason": "", 227 "TaskSignal": "", 228 "DriverMessage": "" 229 }, 230 { 231 "Type": "Started", 232 "Time": 1498775381508493800, 233 "FailsTask": false, 234 "RestartReason": "", 235 "SetupError": "", 236 "DriverError": "", 237 "ExitCode": 0, 238 "Signal": 0, 239 "Message": "", 240 "KillTimeout": 0, 241 "KillError": "", 242 "KillReason": "", 243 "StartDelay": 0, 244 "DownloadError": "", 245 "ValidationError": "", 246 "DiskLimit": 0, 247 "FailedSibling": "", 248 "VaultError": "", 249 "TaskSignalReason": "", 250 "TaskSignal": "", 251 "DriverMessage": "" 252 } 253 ] 254 } 255 }, 256 "DeploymentStatus": null, 257 "CreateIndex": 19, 258 "ModifyIndex": 22, 259 "CreateTime": 1498775380678486300, 260 "ModifyTime": 1498775380678486300 261 } 262 ] 263 ``` 264 265 ## Fail Deployment 266 267 This endpoint is used to mark a deployment as failed. This should be done to 268 force the scheduler to stop creating allocations as part of the deployment or to 269 cause a rollback to a previous job version. This endpoint only triggers a rollback 270 if the most recent stable version of the job has a different specification than 271 the job being reverted. 272 273 | Method | Path | Produces | 274 | ------ | ------------------------------------ | ------------------ | 275 | `POST` | `/v1/deployment/fail/:deployment_id` | `application/json` | 276 277 The table below shows this endpoint's support for 278 [blocking queries](/api-docs#blocking-queries) and 279 [required ACLs](/api-docs#acls). 280 281 | Blocking Queries | ACL Required | 282 | ---------------- | ---------------------- | 283 | `NO` | `namespace:submit-job` | 284 285 ### Parameters 286 287 - `:deployment_id` `(string: <required>)`- Specifies the UUID of the deployment. 288 This must be the full UUID, not the short 8-character one. This is specified 289 as part of the path. 290 291 ### Sample Request 292 293 ```shell-session 294 $ curl \ 295 --request POST \ 296 https://localhost:4646/v1/deployment/fail/5456bd7a-9fc0-c0dd-6131-cbee77f57577 297 ``` 298 299 ### Sample Response 300 301 ```json 302 { 303 "EvalID": "0d834913-58a0-81ac-6e33-e452d83a0c66", 304 "EvalCreateIndex": 20, 305 "DeploymentModifyIndex": 20, 306 "RevertedJobVersion": 1, 307 "Index": 20 308 } 309 ``` 310 311 ## Pause Deployment 312 313 This endpoint is used to pause or unpause a deployment. This is done to pause 314 a rolling upgrade or resume it. 315 316 | Method | Path | Produces | 317 | ------ | ------------------------------------- | ------------------ | 318 | `POST` | `/v1/deployment/pause/:deployment_id` | `application/json` | 319 320 The table below shows this endpoint's support for 321 [blocking queries](/api-docs#blocking-queries) and 322 [required ACLs](/api-docs#acls). 323 324 | Blocking Queries | ACL Required | 325 | ---------------- | ---------------------- | 326 | `NO` | `namespace:submit-job` | 327 328 ### Parameters 329 330 - `:deployment_id` `(string: <required>)`- Specifies the UUID of the deployment. 331 This must be the full UUID, not the short 8-character one. This is specified 332 as part of the path and in the JSON payload. 333 334 - `Pause` `(bool: false)` - Specifies whether to pause or resume the deployment. 335 336 ### Sample Payload 337 338 ```javascript 339 { 340 "DeploymentID": "5456bd7a-9fc0-c0dd-6131-cbee77f57577", 341 "Pause": true 342 } 343 ``` 344 345 ### Sample Request 346 347 ```shell-session 348 $ curl \ 349 --request POST \ 350 https://localhost:4646/v1/deployment/pause/5456bd7a-9fc0-c0dd-6131-cbee77f57577 351 ``` 352 353 ### Sample Response 354 355 ```json 356 { 357 "EvalID": "0d834913-58a0-81ac-6e33-e452d83a0c66", 358 "EvalCreateIndex": 20, 359 "DeploymentModifyIndex": 20, 360 "Index": 20 361 } 362 ``` 363 364 ## Promote Deployment 365 366 This endpoint is used to promote task groups that have canaries for a 367 deployment. This should be done when the placed canaries are healthy and the 368 rolling upgrade of the remaining allocations should begin. 369 370 | Method | Path | Produces | 371 | ------ | --------------------------------------- | ------------------ | 372 | `POST` | `/v1/deployment/promote/:deployment_id` | `application/json` | 373 374 The table below shows this endpoint's support for 375 [blocking queries](/api-docs#blocking-queries) and 376 [required ACLs](/api-docs#acls). 377 378 | Blocking Queries | ACL Required | 379 | ---------------- | ---------------------- | 380 | `NO` | `namespace:submit-job` | 381 382 ### Parameters 383 384 - `:deployment_id` `(string: <required>)`- Specifies the UUID of the deployment. 385 This must be the full UUID, not the short 8-character one. This is specified 386 as part of the path and JSON payload. 387 388 - `All` `(bool: false)` - Specifies whether all task groups should be promoted. 389 390 - `Groups` `(array<string>: nil)` - Specifies a particular set of task groups 391 that should be promoted. 392 393 ### Sample Payload 394 395 ```javascript 396 { 397 "DeploymentID": "5456bd7a-9fc0-c0dd-6131-cbee77f57577", 398 "All": true 399 } 400 ``` 401 402 ```javascript 403 { 404 "DeploymentID": "5456bd7a-9fc0-c0dd-6131-cbee77f57577", 405 "Groups": ["web", "api-server"] 406 } 407 ``` 408 409 ### Sample Request 410 411 ```shell-session 412 $ curl \ 413 --request POST \ 414 https://localhost:4646/v1/deployment/promote/5456bd7a-9fc0-c0dd-6131-cbee77f57577 415 ``` 416 417 ### Sample Response 418 419 ```json 420 { 421 "EvalID": "0d834913-58a0-81ac-6e33-e452d83a0c66", 422 "EvalCreateIndex": 20, 423 "DeploymentModifyIndex": 20, 424 "Index": 20 425 } 426 ``` 427 428 ## Set Allocation Health in Deployment 429 430 This endpoint is used to set the health of an allocation that is in the 431 deployment manually. In some use cases, automatic detection of allocation health 432 may not be desired. As such those task groups can be marked with an upgrade 433 policy that uses `health_check = "manual"`. Those allocations must have their 434 health marked manually using this endpoint. Marking an allocation as healthy 435 will allow the rolling upgrade to proceed. Marking it as failed will cause the 436 deployment to fail. This endpoint only triggers a rollback if the most recent stable 437 version of the job has a different specification than the job being reverted. 438 439 | Method | Path | Produces | 440 | ------ | ------------------------------------------------- | ------------------ | 441 | `POST` | `/v1/deployment/allocation-health/:deployment_id` | `application/json` | 442 443 The table below shows this endpoint's support for 444 [blocking queries](/api-docs#blocking-queries) and 445 [required ACLs](/api-docs#acls). 446 447 | Blocking Queries | ACL Required | 448 | ---------------- | ---------------------- | 449 | `NO` | `namespace:submit-job` | 450 451 ### Parameters 452 453 - `:deployment_id` `(string: <required>)`- Specifies the UUID of the deployment. 454 This must be the full UUID, not the short 8-character one. This is specified 455 as part of the path and the JSON payload. 456 457 - `HealthyAllocationIDs` `(array<string>: nil)` - Specifies the set of 458 allocation that should be marked as healthy. 459 460 - `UnhealthyAllocationIDs` `(array<string>: nil)` - Specifies the set of 461 allocation that should be marked as unhealthy. 462 463 ### Sample Payload 464 465 ```javascript 466 { 467 "DeploymentID": "5456bd7a-9fc0-c0dd-6131-cbee77f57577", 468 "HealthyAllocationIDs": [ 469 "eb13bc8a-7300-56f3-14c0-d4ad115ec3f5", 470 "6584dad8-7ae3-360f-3069-0b4309711cc1" 471 ] 472 } 473 ``` 474 475 ### Sample Request 476 477 ```shell-session 478 $ curl \ 479 --request POST \ 480 https://localhost:4646/v1/deployment/allocation-health/5456bd7a-9fc0-c0dd-6131-cbee77f57577 481 ``` 482 483 ### Sample Response 484 485 ```json 486 { 487 "EvalID": "0d834913-58a0-81ac-6e33-e452d83a0c66", 488 "EvalCreateIndex": 20, 489 "DeploymentModifyIndex": 20, 490 "RevertedJobVersion": 1, 491 "Index": 20 492 } 493 ```