github.com/hspak/nomad@v0.7.2-0.20180309000617-bc4ae22a39a5/website/source/api/nodes.html.md (about)

     1  ---
     2  layout: api
     3  page_title: Nodes - HTTP API
     4  sidebar_current: api-nodes
     5  description: |-
     6    The /node endpoints are used to query for and interact with client nodes.
     7  ---
     8  
     9  # Nodes HTTP API
    10  
    11  The `/node` endpoints are used to query for and interact with client nodes.
    12  
    13  ### List Nodes
    14  
    15  This endpoint lists all nodes registered with Nomad.
    16  
    17  | Method | Path                      | Produces                   |
    18  | ------ | ------------------------- | -------------------------- |
    19  | `GET`  | `/v1/nodes`               | `application/json`         |
    20  
    21  The table below shows this endpoint's support for
    22  [blocking queries](/api/index.html#blocking-queries) and
    23  [required ACLs](/api/index.html#acls).
    24  
    25  | Blocking Queries | ACL Required |
    26  | ---------------- | ------------ |
    27  | `YES`            | `node:read`  |
    28  
    29  ### Parameters
    30  
    31  - `prefix` `(string: "")`- Specifies a string to filter nodes on based on an
    32    index prefix. This is specified as a querystring parameter.
    33  
    34  ### Sample Request
    35  
    36  ```text
    37  $ curl \
    38      https://localhost:4646/v1/nodes
    39  ```
    40  
    41  ```text
    42  $ curl \
    43      https://localhost:4646/v1/nodes?prefix=prod
    44  ```
    45  
    46  ### Sample Response
    47  
    48  ```json
    49  [
    50    {
    51      "ID": "fb2170a8-257d-3c64-b14d-bc06cc94e34c",
    52      "Datacenter": "dc1",
    53      "Name": "bacon-mac",
    54      "NodeClass": "",
    55      "Drain": false,
    56      "Status": "ready",
    57      "StatusDescription": "",
    58      "CreateIndex": 5,
    59      "ModifyIndex": 45
    60    }
    61  ]
    62  ```
    63  
    64  ## Read Node
    65  
    66  This endpoint queries the status of a client node.
    67  
    68  | Method | Path                      | Produces                   |
    69  | ------ | ------------------------- | -------------------------- |
    70  | `GET`  | `/v1/node/:node_id`       | `application/json`         |
    71  
    72  The table below shows this endpoint's support for
    73  [blocking queries](/api/index.html#blocking-queries) and
    74  [required ACLs](/api/index.html#acls).
    75  
    76  | Blocking Queries | ACL Required      |
    77  | ---------------- | ----------------- |
    78  | `YES`            | `node:read`       |
    79  
    80  ### Parameters
    81  
    82  - `:node_id` `(string: <required>)`- Specifies the ID of the node. This must be
    83    the full UUID, not the short 8-character one. This is specified as part of the
    84    path.
    85  
    86  ### Sample Request
    87  
    88  ```text
    89  $ curl \
    90      https://localhost:4646/v1/node/fb2170a8-257d-3c64-b14d-bc06cc94e34c
    91  ```
    92  
    93  ### Sample Response
    94  
    95  ```json
    96  {
    97    "ID": "fb2170a8-257d-3c64-b14d-bc06cc94e34c",
    98    "SecretID": "",
    99    "Datacenter": "dc1",
   100    "Name": "bacon-mac",
   101    "HTTPAddr": "127.0.0.1:4646",
   102    "TLSEnabled": false,
   103    "Attributes": {
   104      "os.version": "10.12.5",
   105      "cpu.modelname": "Intel(R) Core(TM) i7-3615QM CPU @ 2.30GHz",
   106      "nomad.revision": "f551dcb83e3ac144c9dbb90583b6e82d234662e9",
   107      "driver.docker.volumes.enabled": "1",
   108      "driver.docker": "1",
   109      "cpu.frequency": "2300",
   110      "memory.totalbytes": "17179869184",
   111      "driver.mock_driver": "1",
   112      "kernel.version": "16.6.0",
   113      "unique.network.ip-address": "127.0.0.1",
   114      "nomad.version": "0.5.5dev",
   115      "unique.hostname": "bacon-mac",
   116      "cpu.arch": "amd64",
   117      "os.name": "darwin",
   118      "kernel.name": "darwin",
   119      "unique.storage.volume": "/dev/disk1",
   120      "driver.docker.version": "17.03.1-ce",
   121      "cpu.totalcompute": "18400",
   122      "unique.storage.bytestotal": "249783500800",
   123      "cpu.numcores": "8",
   124      "os.signals": "SIGCONT,SIGSTOP,SIGSYS,SIGINT,SIGIOT,SIGXCPU,SIGSEGV,SIGUSR1,SIGTTIN,SIGURG,SIGUSR2,SIGABRT,SIGALRM,SIGCHLD,SIGFPE,SIGTSTP,SIGIO,SIGKILL,SIGQUIT,SIGXFSZ,SIGBUS,SIGHUP,SIGPIPE,SIGPROF,SIGTRAP,SIGTTOU,SIGILL,SIGTERM",
   125      "driver.raw_exec": "1",
   126      "unique.storage.bytesfree": "142954643456"
   127    },
   128    "Resources": {
   129      "CPU": 18400,
   130      "MemoryMB": 16384,
   131      "DiskMB": 136332,
   132      "IOPS": 0,
   133      "Networks": [
   134        {
   135          "Device": "lo0",
   136          "CIDR": "127.0.0.1/32",
   137          "IP": "127.0.0.1",
   138          "MBits": 1000,
   139          "ReservedPorts": null,
   140          "DynamicPorts": null
   141        }
   142      ]
   143    },
   144    "Reserved": {
   145      "CPU": 0,
   146      "MemoryMB": 0,
   147      "DiskMB": 0,
   148      "IOPS": 0,
   149      "Networks": null
   150    },
   151    "Links": null,
   152    "Meta": null,
   153    "NodeClass": "",
   154    "ComputedClass": "v1:10952212473894849978",
   155    "Drain": false,
   156    "Status": "ready",
   157    "StatusDescription": "",
   158    "StatusUpdatedAt": 1495748907,
   159    "CreateIndex": 5,
   160    "ModifyIndex": 45
   161  }
   162  ```
   163  
   164  ## List Node Allocations
   165  
   166  This endpoint lists all of the allocations for the given node. This can be used to 
   167  determine what allocations have been scheduled on the node, their current status,
   168  and the values of dynamically assigned resources, like ports.
   169  
   170  | Method  | Path                            | Produces                   |
   171  | ------- | ------------------------------- | -------------------------- |
   172  | `GET`   | `/v1/node/:node_id/allocations` | `application/json`         |
   173  
   174  The table below shows this endpoint's support for
   175  [blocking queries](/api/index.html#blocking-queries) and
   176  [required ACLs](/api/index.html#acls).
   177  
   178  | Blocking Queries | ACL Required                   |
   179  | ---------------- | ------------------------------ |
   180  | `YES`            | `node:read,namespace:read-job` |
   181  
   182  ### Parameters
   183  
   184  - `:node_id` `(string: <required>)`- Specifies the UUID of the node. This must
   185    be the full UUID, not the short 8-character one. This is specified as part of
   186    the path.
   187  
   188  ### Sample Request
   189  
   190  ```text
   191  $ curl \
   192      https://localhost:4646/v1/node/e02b6169-83bd-9df6-69bd-832765f333eb/allocations
   193  ```
   194  
   195  ### Sample Response
   196  
   197  ```json
   198  [
   199    {
   200      "ID": "8dfa702d-0c03-6fd4-ade6-386d72fb8192",
   201      "EvalID": "a128568e-6cc6-0f95-f37d-3fd4c8123316",
   202      "Name": "example.cache[0]",
   203      "NodeID": "05129072-6258-4ea6-79bf-03bd31418ac7",
   204      "JobID": "example",
   205      "Job": {
   206        "Stop": false,
   207        "Region": "global",
   208        "ID": "example",
   209        "ParentID": "",
   210        "Name": "example",
   211        "Type": "service",
   212        "Priority": 50,
   213        "AllAtOnce": false,
   214        "Datacenters": [
   215          "dc1"
   216        ],
   217        "Constraints": null,
   218        "TaskGroups": [
   219          {
   220            "Name": "cache",
   221            "Count": 1,
   222            "Update": {
   223              "Stagger": 10000000000,
   224              "MaxParallel": 1,
   225              "HealthCheck": "checks",
   226              "MinHealthyTime": 10000000000,
   227              "HealthyDeadline": 300000000000,
   228              "AutoRevert": false,
   229              "Canary": 0
   230            },
   231            "Constraints": null,
   232            "RestartPolicy": {
   233              "Attempts": 10,
   234              "Interval": 300000000000,
   235              "Delay": 25000000000,
   236              "Mode": "delay"
   237            },
   238            "Tasks": [
   239              {
   240                "Name": "redis",
   241                "Driver": "docker",
   242                "User": "",
   243                "Config": {
   244                  "image": "redis:3.2",
   245                  "port_map": [
   246                    {
   247                      "db": 6379
   248                    }
   249                  ]
   250                },
   251                "Env": null,
   252                "Services": [
   253                  {
   254                    "Name": "redis-cache",
   255                    "PortLabel": "db",
   256                    "AddressMode": "auto",
   257                    "Tags": [
   258                      "global",
   259                      "cache"
   260                    ],
   261                    "Checks": [
   262                      {
   263                        "Name": "alive",
   264                        "Type": "tcp",
   265                        "Command": "",
   266                        "Args": null,
   267                        "Path": "",
   268                        "Protocol": "",
   269                        "PortLabel": "",
   270                        "Interval": 10000000000,
   271                        "Timeout": 2000000000,
   272                        "InitialStatus": "",
   273                        "TLSSkipVerify": false
   274                      }
   275                    ]
   276                  }
   277                ],
   278                "Vault": null,
   279                "Templates": null,
   280                "Constraints": null,
   281                "Resources": {
   282                  "CPU": 500,
   283                  "MemoryMB": 256,
   284                  "DiskMB": 0,
   285                  "IOPS": 0,
   286                  "Networks": [
   287                    {
   288                      "Device": "",
   289                      "CIDR": "",
   290                      "IP": "",
   291                      "MBits": 10,
   292                      "ReservedPorts": null,
   293                      "DynamicPorts": [
   294                        {
   295                          "Label": "db",
   296                          "Value": 0
   297                        }
   298                      ]
   299                    }
   300                  ]
   301                },
   302                "DispatchPayload": null,
   303                "Meta": null,
   304                "KillTimeout": 5000000000,
   305                "LogConfig": {
   306                  "MaxFiles": 10,
   307                  "MaxFileSizeMB": 10
   308                },
   309                "Artifacts": null,
   310                "Leader": false
   311              }
   312            ],
   313            "EphemeralDisk": {
   314              "Sticky": false,
   315              "SizeMB": 300,
   316              "Migrate": false
   317            },
   318            "Meta": null
   319          }
   320        ],
   321        "Update": {
   322          "Stagger": 10000000000,
   323          "MaxParallel": 1,
   324          "HealthCheck": "",
   325          "MinHealthyTime": 0,
   326          "HealthyDeadline": 0,
   327          "AutoRevert": false,
   328          "Canary": 0
   329        },
   330        "Periodic": null,
   331        "ParameterizedJob": null,
   332        "Payload": null,
   333        "Meta": null,
   334        "VaultToken": "",
   335        "Status": "pending",
   336        "StatusDescription": "",
   337        "Stable": false,
   338        "Version": 0,
   339        "SubmitTime": 1502140975490599700,
   340        "CreateIndex": 15050,
   341        "ModifyIndex": 15050,
   342        "JobModifyIndex": 15050
   343      },
   344      "TaskGroup": "cache",
   345      "Resources": {
   346        "CPU": 500,
   347        "MemoryMB": 256,
   348        "DiskMB": 300,
   349        "IOPS": 0,
   350        "Networks": [
   351          {
   352            "Device": "eth0",
   353            "CIDR": "",
   354            "IP": "10.0.0.226",
   355            "MBits": 10,
   356            "ReservedPorts": null,
   357            "DynamicPorts": [
   358              {
   359                "Label": "db",
   360                "Value": 22908
   361              }
   362            ]
   363          }
   364        ]
   365      },
   366      "SharedResources": {
   367        "CPU": 0,
   368        "MemoryMB": 0,
   369        "DiskMB": 300,
   370        "IOPS": 0,
   371        "Networks": null
   372      },
   373      "TaskResources": {
   374        "redis": {
   375          "CPU": 500,
   376          "MemoryMB": 256,
   377          "DiskMB": 0,
   378          "IOPS": 0,
   379          "Networks": [
   380            {
   381              "Device": "eth0",
   382              "CIDR": "",
   383              "IP": "10.0.0.226",
   384              "MBits": 10,
   385              "ReservedPorts": null,
   386              "DynamicPorts": [
   387                {
   388                  "Label": "db",
   389                  "Value": 22908
   390                }
   391              ]
   392            }
   393          ]
   394        }
   395      },
   396      "Metrics": {
   397        "NodesEvaluated": 2,
   398        "NodesFiltered": 0,
   399        "NodesAvailable": {
   400          "dc1": 3
   401        },
   402        "ClassFiltered": null,
   403        "ConstraintFiltered": null,
   404        "NodesExhausted": 0,
   405        "ClassExhausted": null,
   406        "DimensionExhausted": null,
   407        "Scores": {
   408          "1dabfc7d-a92f-00f2-1cb6-0be3f000e542.binpack": 8.269190730718089
   409        },
   410        "AllocationTime": 41183,
   411        "CoalescedFailures": 0
   412      },
   413      "DesiredStatus": "run",
   414      "DesiredDescription": "",
   415      "ClientStatus": "running",
   416      "ClientDescription": "",
   417      "TaskStates": {
   418        "redis": {
   419          "State": "running",
   420          "Failed": false,
   421          "Restarts": 0,
   422          "LastRestart": "0001-01-01T00:00:00Z",
   423          "StartedAt": "2017-08-07T21:22:59.326433825Z",
   424          "FinishedAt": "0001-01-01T00:00:00Z",
   425          "Events": [
   426            {
   427              "Type": "Received",
   428              "Time": 1502140975648341200,
   429              "FailsTask": false,
   430              "RestartReason": "",
   431              "SetupError": "",
   432              "DriverError": "",
   433              "ExitCode": 0,
   434              "Signal": 0,
   435              "Message": "",
   436              "KillTimeout": 0,
   437              "KillError": "",
   438              "KillReason": "",
   439              "StartDelay": 0,
   440              "DownloadError": "",
   441              "ValidationError": "",
   442              "DiskLimit": 0,
   443              "FailedSibling": "",
   444              "VaultError": "",
   445              "TaskSignalReason": "",
   446              "TaskSignal": "",
   447              "DriverMessage": ""
   448            },
   449            {
   450              "Type": "Task Setup",
   451              "Time": 1502140975648601000,
   452              "FailsTask": false,
   453              "RestartReason": "",
   454              "SetupError": "",
   455              "DriverError": "",
   456              "ExitCode": 0,
   457              "Signal": 0,
   458              "Message": "Building Task Directory",
   459              "KillTimeout": 0,
   460              "KillError": "",
   461              "KillReason": "",
   462              "StartDelay": 0,
   463              "DownloadError": "",
   464              "ValidationError": "",
   465              "DiskLimit": 0,
   466              "FailedSibling": "",
   467              "VaultError": "",
   468              "TaskSignalReason": "",
   469              "TaskSignal": "",
   470              "DriverMessage": ""
   471            },
   472            {
   473              "Type": "Started",
   474              "Time": 1502140979184330000,
   475              "FailsTask": false,
   476              "RestartReason": "",
   477              "SetupError": "",
   478              "DriverError": "",
   479              "ExitCode": 0,
   480              "Signal": 0,
   481              "Message": "",
   482              "KillTimeout": 0,
   483              "KillError": "",
   484              "KillReason": "",
   485              "StartDelay": 0,
   486              "DownloadError": "",
   487              "ValidationError": "",
   488              "DiskLimit": 0,
   489              "FailedSibling": "",
   490              "VaultError": "",
   491              "TaskSignalReason": "",
   492              "TaskSignal": "",
   493              "DriverMessage": ""
   494            }
   495          ]
   496        }
   497      },
   498      "PreviousAllocation": "",
   499      "DeploymentID": "ea696568-4518-0099-6811-9c26425c60af",
   500      "DeploymentStatus": {
   501        "Healthy": true,
   502        "ModifyIndex": 15057
   503      },
   504      "CreateIndex": 15052,
   505      "ModifyIndex": 15057,
   506      "AllocModifyIndex": 15052,
   507      "CreateTime": 1502140975600438500,
   508      "ModifyTime": 1502140975600438500
   509    },
   510  ...
   511  ]
   512  ```
   513      
   514  ## Create Node Evaluation
   515  
   516  This endpoint creates a new evaluation for the given node. This can be used to
   517  force a run of the scheduling logic.
   518  
   519  | Method  | Path                         | Produces                   |
   520  | ------- | ---------------------------- | -------------------------- |
   521  | `POST`  | `/v1/node/:node_id/evaluate` | `application/json`         |
   522  
   523  The table below shows this endpoint's support for
   524  [blocking queries](/api/index.html#blocking-queries) and
   525  [required ACLs](/api/index.html#acls).
   526  
   527  | Blocking Queries | ACL Required       |
   528  | ---------------- | ------------------ |
   529  | `NO`             | `node:write`       |
   530  
   531  ### Parameters
   532  
   533  - `:node_id` `(string: <required>)`- Specifies the UUID of the node. This must
   534    be the full UUID, not the short 8-character one. This is specified as part of
   535    the path.
   536  
   537  ### Sample Request
   538  
   539  ```text
   540  $ curl \
   541      https://localhost:4646/v1/node/fb2170a8-257d-3c64-b14d-bc06cc94e34c/evaluate
   542  ```
   543  
   544  ### Sample Response
   545  
   546  ```json
   547  {
   548    "HeartbeatTTL": 0,
   549    "EvalIDs": [
   550      "4ff1c7a2-c650-4058-f509-d5028ff9566e"
   551    ],
   552    "EvalCreateIndex": 85,
   553    "NodeModifyIndex": 0,
   554    "LeaderRPCAddr": "127.0.0.1:4647",
   555    "NumNodes": 1,
   556    "Servers": [
   557      {
   558        "RPCAdvertiseAddr": "127.0.0.1:4647",
   559        "RPCMajorVersion": 1,
   560        "RPCMinorVersion": 1,
   561        "Datacenter": "dc1"
   562      }
   563    ],
   564    "Index": 85,
   565    "LastContact": 0,
   566    "KnownLeader": false
   567  }
   568  ```
   569  
   570  ## Drain Node
   571  
   572  This endpoint toggles the drain mode of the node. When draining is enabled, no
   573  further allocations will be assigned to this node, and existing allocations will
   574  be migrated to new nodes.
   575  
   576  | Method  | Path                      | Produces                   |
   577  | ------- | ------------------------- | -------------------------- |
   578  | `POST`  | `/v1/node/:node_id/drain` | `application/json`         |
   579  
   580  The table below shows this endpoint's support for
   581  [blocking queries](/api/index.html#blocking-queries) and
   582  [required ACLs](/api/index.html#acls).
   583  
   584  | Blocking Queries | ACL Required       |
   585  | ---------------- | ------------------ |
   586  | `NO`             | `node:write`       |
   587  
   588  ### Parameters
   589  
   590  - `:node_id` `(string: <required>)`- Specifies the UUID of the node. This must
   591    be the full UUID, not the short 8-character one. This is specified as part of
   592    the path.
   593  
   594  - `enable` `(bool: <required>)` - Specifies if drain mode should be enabled.
   595    This is specified as a query string parameter.
   596  
   597  ### Sample Request
   598  
   599  ```text
   600  $ curl \
   601      -XPOST https://localhost:4646/v1/node/fb2170a8-257d-3c64-b14d-bc06cc94e34c/drain?enable=true
   602  ```
   603  
   604  ### Sample Response
   605  
   606  ```json
   607  {
   608    "EvalIDs": [
   609      "253ec083-22a7-76c9-b8b6-2bf3d4b27bfb"
   610    ],
   611    "EvalCreateIndex": 91,
   612    "NodeModifyIndex": 90,
   613    "Index": 90,
   614    "LastContact": 0,
   615    "KnownLeader": false
   616  }
   617  ```
   618  
   619  ## Purge Node
   620  
   621  This endpoint purges a node from the system. Nodes can still join the cluster if
   622  they are alive.
   623  
   624  | Method  | Path                      | Produces                   |
   625  | ------- | ------------------------- | -------------------------- |
   626  | `POST`  | `/v1/node/:node_id/purge` | `application/json`         |
   627  
   628  The table below shows this endpoint's support for
   629  [blocking queries](/api/index.html#blocking-queries) and
   630  [required ACLs](/api/index.html#acls).
   631  
   632  | Blocking Queries | ACL Required       |
   633  | ---------------- | ------------------ |
   634  | `NO`             | `node:write`       |
   635  
   636  ### Parameters
   637  
   638  - `:node_id` `(string: <required>)`- Specifies the UUID of the node. This must
   639    be the full UUID, not the short 8-character one. This is specified as part of
   640    the path.
   641  
   642  ### Sample Request
   643  
   644  ```text
   645  $ curl \
   646      -XPOST https://localhost:4646/v1/node/fb2170a8-257d-3c64-b14d-bc06cc94e34c/purge
   647  ```
   648  
   649  ### Sample Response
   650  
   651  ```json
   652  {
   653    "EvalIDs": [
   654      "253ec083-22a7-76c9-b8b6-2bf3d4b27bfb"
   655    ],
   656    "EvalCreateIndex": 91,
   657    "NodeModifyIndex": 90,
   658    "Index": 90,
   659    "LastContact": 0,
   660    "KnownLeader": false
   661  }
   662  ```