github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/website/content/api-docs/deployments.mdx (about)

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