github.com/iqoqo/nomad@v0.11.3-0.20200911112621-d7021c74d101/website/pages/api-docs/operator.mdx (about)

     1  ---
     2  layout: api
     3  page_title: Operator - HTTP API
     4  sidebar_title: Operator
     5  description: |-
     6    The /operator endpoints provides cluster-level tools for Nomad operators, such
     7    as interacting with the Raft subsystem.
     8  ---
     9  
    10  # /v1/operator
    11  
    12  The `/operator` endpoint provides cluster-level tools for Nomad operators, such
    13  as interacting with the Raft subsystem.
    14  
    15  ~> Use this interface with extreme caution, as improper use could lead to a
    16  Nomad outage and even loss of data.
    17  
    18  See the [Outage Recovery](https://learn.hashicorp.com/nomad/operating-nomad/outage) guide for some examples of how
    19  these capabilities are used. For a CLI to perform these operations manually,
    20  please see the documentation for the
    21  [`nomad operator`](/docs/commands/operator) command.
    22  
    23  ## Read Raft Configuration
    24  
    25  This endpoint queries the status of a client node registered with Nomad.
    26  
    27  | Method | Path                              | Produces           |
    28  | ------ | --------------------------------- | ------------------ |
    29  | `GET`  | `/v1/operator/raft/configuration` | `application/json` |
    30  
    31  The table below shows this endpoint's support for
    32  [blocking queries](/api-docs#blocking-queries) and
    33  [required ACLs](/api-docs#acls).
    34  
    35  | Blocking Queries | ACL Required |
    36  | ---------------- | ------------ |
    37  | `NO`             | `management` |
    38  
    39  ### Parameters
    40  
    41  - `stale` - Specifies if the cluster should respond without an active leader.
    42    This is specified as a query string parameter.
    43  
    44  ### Sample Request
    45  
    46  ```shell-sessioncurl \
    47      https://localhost:4646/v1/operator/raft/configuration
    48  ```
    49  
    50  ### Sample Response
    51  
    52  ```json
    53  {
    54    "Index": 1,
    55    "Servers": [
    56      {
    57        "Address": "127.0.0.1:4647",
    58        "ID": "127.0.0.1:4647",
    59        "Leader": true,
    60        "Node": "bacon-mac.global",
    61        "RaftProtocol": 2,
    62        "Voter": true
    63      }
    64    ]
    65  }
    66  ```
    67  
    68  #### Field Reference
    69  
    70  - `Index` `(int)` - The `Index` value is the Raft corresponding to this
    71    configuration. The latest configuration may not yet be committed if changes
    72    are in flight.
    73  
    74  - `Servers` `(array: Server)` - The returned `Servers` array has information
    75    about the servers in the Raft peer configuration.
    76  
    77    - `ID` `(string)` - The ID of the server. This is the same as the `Address`
    78      but may be upgraded to a GUID in a future version of Nomad.
    79  
    80    - `Node` `(string)` - The node name of the server, as known to Nomad, or
    81      `"(unknown)"` if the node is stale and not known.
    82  
    83    - `Address` `(string)` - The `ip:port` for the server.
    84  
    85    - `Leader` `(bool)` - is either "true" or "false" depending on the server's
    86      role in the Raft configuration.
    87  
    88    - `Voter` `(bool)` - is "true" or "false", indicating if the server has a vote
    89      in the Raft configuration. Future versions of Nomad may add support for
    90      non-voting servers.
    91  
    92  ## Remove Raft Peer
    93  
    94  This endpoint removes a Nomad server with given address from the Raft
    95  configuration. The return code signifies success or failure.
    96  
    97  | Method   | Path                     | Produces           |
    98  | -------- | ------------------------ | ------------------ |
    99  | `DELETE` | `/v1/operator/raft/peer` | `application/json` |
   100  
   101  The table below shows this endpoint's support for
   102  [blocking queries](/api-docs#blocking-queries) and
   103  [required ACLs](/api-docs#acls).
   104  
   105  | Blocking Queries | ACL Required |
   106  | ---------------- | ------------ |
   107  | `NO`             | `management` |
   108  
   109  ### Parameters
   110  
   111  - `address` `(string: <optional>)` - Specifies the server to remove as
   112    `ip:port`. This cannot be provided along with the `id` parameter.
   113  
   114  - `id` `(string: <optional>)` - Specifies the server to remove as
   115    `id`. This cannot be provided along with the `address` parameter.
   116  
   117  ### Sample Request
   118  
   119  ```shell-sessioncurl \
   120      --request DELETE \
   121      https://localhost:4646/v1/operator/raft/peer?address=1.2.3.4
   122  ```
   123  
   124  ## Read Autopilot Configuration
   125  
   126  This endpoint retrieves its latest Autopilot configuration.
   127  
   128  | Method | Path                                   | Produces           |
   129  | ------ | -------------------------------------- | ------------------ |
   130  | `GET`  | `/v1/operator/autopilot/configuration` | `application/json` |
   131  
   132  The table below shows this endpoint's support for
   133  [blocking queries](/api-docs#blocking-queries) and
   134  [required ACLs](/api-docs#acls).
   135  
   136  | Blocking Queries | ACL Required    |
   137  | ---------------- | --------------- |
   138  | `NO`             | `operator:read` |
   139  
   140  ### Sample Request
   141  
   142  ```shell-sessioncurl \
   143      https://localhost:4646/v1/operator/autopilot/configuration
   144  ```
   145  
   146  ### Sample Response
   147  
   148  ```json
   149  {
   150    "CleanupDeadServers": true,
   151    "LastContactThreshold": "200ms",
   152    "MaxTrailingLogs": 250,
   153    "ServerStabilizationTime": "10s",
   154    "EnableRedundancyZones": false,
   155    "DisableUpgradeMigration": false,
   156    "EnableCustomUpgrades": false,
   157    "CreateIndex": 4,
   158    "ModifyIndex": 4
   159  }
   160  ```
   161  
   162  For more information about the Autopilot configuration options, see the
   163  [agent configuration section](/docs/configuration/autopilot).
   164  
   165  ## Update Autopilot Configuration
   166  
   167  This endpoint updates the Autopilot configuration of the cluster.
   168  
   169  | Method | Path                                   | Produces           |
   170  | ------ | -------------------------------------- | ------------------ |
   171  | `PUT`  | `/v1/operator/autopilot/configuration` | `application/json` |
   172  
   173  The table below shows this endpoint's support for
   174  [blocking queries](/api-docs#blocking-queries) and
   175  [required ACLs](/api-docs#acls).
   176  
   177  | Blocking Queries | ACL Required     |
   178  | ---------------- | ---------------- |
   179  | `NO`             | `operator:write` |
   180  
   181  ### Parameters
   182  
   183  - `cas` `(int: 0)` - Specifies to use a Check-And-Set operation. The update will
   184    only happen if the given index matches the `ModifyIndex` of the configuration
   185    at the time of writing.
   186  
   187  ### Sample Payload
   188  
   189  ```json
   190  {
   191    "CleanupDeadServers": true,
   192    "LastContactThreshold": "200ms",
   193    "MaxTrailingLogs": 250,
   194    "ServerStabilizationTime": "10s",
   195    "EnableRedundancyZones": false,
   196    "DisableUpgradeMigration": false,
   197    "EnableCustomUpgrades": false,
   198    "CreateIndex": 4,
   199    "ModifyIndex": 4
   200  }
   201  ```
   202  
   203  - `CleanupDeadServers` `(bool: true)` - Specifies automatic removal of dead
   204    server nodes periodically and whenever a new server is added to the cluster.
   205  
   206  - `LastContactThreshold` `(string: "200ms")` - Specifies the maximum amount of
   207    time a server can go without contact from the leader before being considered
   208    unhealthy. Must be a duration value such as `10s`.
   209  
   210  - `MaxTrailingLogs` `(int: 250)` specifies the maximum number of log entries
   211    that a server can trail the leader by before being considered unhealthy.
   212  
   213  - `ServerStabilizationTime` `(string: "10s")` - Specifies the minimum amount of
   214    time a server must be stable in the 'healthy' state before being added to the
   215    cluster. Only takes effect if all servers are running Raft protocol version 3
   216    or higher. Must be a duration value such as `30s`.
   217  
   218  - `EnableRedundancyZones` `(bool: false)` - (Enterprise-only) Specifies whether
   219    to enable redundancy zones.
   220  
   221  - `DisableUpgradeMigration` `(bool: false)` - (Enterprise-only) Disables Autopilot's
   222    upgrade migration strategy in Nomad Enterprise of waiting until enough
   223    newer-versioned servers have been added to the cluster before promoting any of
   224    them to voters.
   225  
   226  - `EnableCustomUpgrades` `(bool: false)` - (Enterprise-only) Specifies whether to
   227    enable using custom upgrade versions when performing migrations.
   228  
   229  ## Read Health
   230  
   231  This endpoint queries the health of the autopilot status.
   232  
   233  | Method | Path                            | Produces           |
   234  | ------ | ------------------------------- | ------------------ |
   235  | `GET`  | `/v1/operator/autopilot/health` | `application/json` |
   236  
   237  The table below shows this endpoint's support for
   238  [blocking queries](/api-docs#blocking-queries) and
   239  [required ACLs](/api-docs#acls).
   240  
   241  | Blocking Queries | ACL Required    |
   242  | ---------------- | --------------- |
   243  | `NO`             | `operator:read` |
   244  
   245  ### Sample Request
   246  
   247  ```shell-sessioncurl \
   248      https://localhost:4646/v1/operator/autopilot/health
   249  ```
   250  
   251  ### Sample response
   252  
   253  ```json
   254  {
   255    "Healthy": true,
   256    "FailureTolerance": 0,
   257    "Servers": [
   258      {
   259        "ID": "e349749b-3303-3ddf-959c-b5885a0e1f6e",
   260        "Name": "node1",
   261        "Address": "127.0.0.1:8300",
   262        "SerfStatus": "alive",
   263        "Version": "0.8.0",
   264        "Leader": true,
   265        "LastContact": "0s",
   266        "LastTerm": 2,
   267        "LastIndex": 46,
   268        "Healthy": true,
   269        "Voter": true,
   270        "StableSince": "2017-03-06T22:07:51Z"
   271      },
   272      {
   273        "ID": "e36ee410-cc3c-0a0c-c724-63817ab30303",
   274        "Name": "node2",
   275        "Address": "127.0.0.1:8205",
   276        "SerfStatus": "alive",
   277        "Version": "0.8.0",
   278        "Leader": false,
   279        "LastContact": "27.291304ms",
   280        "LastTerm": 2,
   281        "LastIndex": 46,
   282        "Healthy": true,
   283        "Voter": false,
   284        "StableSince": "2017-03-06T22:18:26Z"
   285      }
   286    ]
   287  }
   288  ```
   289  
   290  - `Healthy` is whether all the servers are currently healthy.
   291  
   292  - `FailureTolerance` is the number of redundant healthy servers that could be
   293    fail without causing an outage (this would be 2 in a healthy cluster of 5
   294    servers).
   295  
   296  - `Servers` holds detailed health information on each server:
   297  
   298    - `ID` is the Raft ID of the server.
   299  
   300    - `Name` is the node name of the server.
   301  
   302    - `Address` is the address of the server.
   303  
   304    - `SerfStatus` is the SerfHealth check status for the server.
   305  
   306    - `Version` is the Nomad version of the server.
   307  
   308    - `Leader` is whether this server is currently the leader.
   309  
   310    - `LastContact` is the time elapsed since this server's last contact with the leader.
   311  
   312    - `LastTerm` is the server's last known Raft leader term.
   313  
   314    - `LastIndex` is the index of the server's last committed Raft log entry.
   315  
   316    - `Healthy` is whether the server is healthy according to the current Autopilot configuration.
   317  
   318    - `Voter` is whether the server is a voting member of the Raft cluster.
   319  
   320    - `StableSince` is the time this server has been in its current `Healthy` state.
   321  
   322    The HTTP status code will indicate the health of the cluster. If `Healthy` is true, then a
   323    status of 200 will be returned. If `Healthy` is false, then a status of 429 will be returned.
   324  
   325  ## Read Scheduler Configuration
   326  
   327  This endpoint retrieves the latest Scheduler configuration. This API was introduced in
   328  Nomad 0.9 and currently supports enabling/disabling preemption. More options may be added in
   329  the future.
   330  
   331  | Method | Path                                   | Produces           |
   332  | ------ | -------------------------------------- | ------------------ |
   333  | `GET`  | `/v1/operator/scheduler/configuration` | `application/json` |
   334  
   335  The table below shows this endpoint's support for
   336  [blocking queries](/api-docs#blocking-queries) and
   337  [required ACLs](/api-docs#acls).
   338  
   339  | Blocking Queries | ACL Required    |
   340  | ---------------- | --------------- |
   341  | `NO`             | `operator:read` |
   342  
   343  ### Sample Request
   344  
   345  ```shell-sessioncurl \
   346      https://localhost:4646/v1/operator/scheduler/configuration
   347  ```
   348  
   349  ### Sample Response
   350  
   351  ```json
   352  {
   353    "Index": 5,
   354    "KnownLeader": true,
   355    "LastContact": 0,
   356    "SchedulerConfig": {
   357      "CreateIndex": 5,
   358      "ModifyIndex": 5,
   359      "SchedulerAlgorithm": "spread",
   360      "PreemptionConfig": {
   361        "SystemSchedulerEnabled": true,
   362        "BatchSchedulerEnabled": false,
   363        "ServiceSchedulerEnabled": false
   364      }
   365    }
   366  }
   367  ```
   368  
   369  #### Field Reference
   370  
   371  - `Index` `(int)` - The `Index` value is the Raft commit index corresponding to this
   372    configuration.
   373  
   374  - `SchedulerConfig` `(SchedulerConfig)` - The returned `SchedulerConfig` object has configuration
   375    settings mentioned below.
   376  
   377    - `SchedulerAlgorithm` `(string: "binpack")` - Specifies whether scheduler binpacks or spreads allocations on available nodes.
   378  
   379    - `PreemptionConfig` `(PreemptionConfig)` - Options to enable preemption for various schedulers.
   380  
   381      - `SystemSchedulerEnabled` `(bool: true)` - Specifies whether preemption for system jobs is enabled. Note that
   382      this defaults to true.
   383  
   384      - `BatchSchedulerEnabled` `(bool: false)` (Enterprise Only) - Specifies whether preemption for batch jobs is enabled. Note that
   385      this defaults to false and must be explicitly enabled.
   386  
   387      - `ServiceSchedulerEnabled` `(bool: false)` (Enterprise Only) - Specifies whether preemption for service jobs is enabled. Note that
   388      this defaults to false and must be explicitly enabled.
   389  
   390    - `CreateIndex` - The Raft index at which the config was created.
   391    - `ModifyIndex` - The Raft index at which the config was modified.
   392  
   393  ## Update Scheduler Configuration
   394  
   395  This endpoint updates the scheduler configuration of the cluster.
   396  
   397  | Method        | Path                                   | Produces           |
   398  | ------------- | -------------------------------------- | ------------------ |
   399  | `PUT`, `POST` | `/v1/operator/scheduler/configuration` | `application/json` |
   400  
   401  The table below shows this endpoint's support for
   402  [blocking queries](/api-docs#blocking-queries) and
   403  [required ACLs](/api-docs#acls).
   404  
   405  | Blocking Queries | ACL Required     |
   406  | ---------------- | ---------------- |
   407  | `NO`             | `operator:write` |
   408  
   409  ### Parameters
   410  
   411  - `cas` `(int: 0)` - Specifies to use a Check-And-Set operation. The update will
   412    only happen if the given index matches the `ModifyIndex` of the configuration
   413    at the time of writing.
   414  
   415  ### Sample Payload
   416  
   417  ```json
   418  {
   419    "SchedulerAlgorithm": "spread",
   420    "PreemptionConfig": {
   421      "SystemSchedulerEnabled": true,
   422      "BatchSchedulerEnabled": false,
   423      "ServiceSchedulerEnabled": true
   424    }
   425  }
   426  ```
   427  
   428  - `SchedulerAlgorithm` `(string: "binpack")` - Specifies whether scheduler binpacks or spreads allocations on available nodes.  Possible values are `"binpack"` and `"spread"`
   429  - `PreemptionConfig` `(PreemptionConfig)` - Options to enable preemption for various schedulers.
   430  - `SystemSchedulerEnabled` `(bool: true)` - Specifies whether preemption for system jobs is enabled. Note that
   431    if this is set to true, then system jobs can preempt any other jobs.
   432  - `BatchSchedulerEnabled` `(bool: false)` (Enterprise Only) - Specifies whether preemption for batch jobs is enabled. Note that
   433    if this is set to true, then batch jobs can preempt any other jobs.
   434  - `ServiceSchedulerEnabled` `(bool: false)` (Enterprise Only) - Specifies whether preemption for service jobs is enabled. Note that
   435    if this is set to true, then service jobs can preempt any other jobs.