github.com/zoomfoo/nomad@v0.8.5-0.20180907175415-f28fd3a1a056/website/source/api/operator.html.md (about)

     1  ---
     2  layout: api
     3  page_title: Operator - HTTP API
     4  sidebar_current: api-operator
     5  description: |-
     6    The /operator endpoints provides cluster-level tools for Nomad operators, such
     7    as interacting with the Raft subsystem.
     8  ---
     9  # /v1/operator
    10  
    11  The `/operator` endpoint provides cluster-level tools for Nomad operators, such
    12  as interacting with the Raft subsystem.
    13  
    14  ~> Use this interface with extreme caution, as improper use could lead to a
    15  Nomad outage and even loss of data.
    16  
    17  See the [Outage Recovery](/guides/operations/outage.html) guide for some examples of how
    18  these capabilities are used. For a CLI to perform these operations manually,
    19  please see the documentation for the
    20  [`nomad operator`](/docs/commands/operator.html) command.
    21  
    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/index.html#blocking-queries) and
    33  [required ACLs](/api/index.html#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 querystring parameter.
    43  
    44  ### Sample Request
    45  
    46  ```text
    47  $ curl \
    48      https://localhost:4646/v1/operator/raft/configuration
    49  ```
    50  
    51  ### Sample Response
    52  
    53  ```json
    54  {
    55    "Index": 1,
    56    "Servers": [
    57      {
    58        "Address": "127.0.0.1:4647",
    59        "ID": "127.0.0.1:4647",
    60        "Leader": true,
    61        "Node": "bacon-mac.global",
    62        "RaftProtocol": 2,
    63        "Voter": true
    64      }
    65    ]
    66  }
    67  ```
    68  
    69  #### Field Reference
    70  
    71  - `Index` `(int)` - The `Index` value is the Raft corresponding to this
    72    configuration. The latest configuration may not yet be committed if changes
    73    are in flight.
    74  
    75  - `Servers` `(array: Server)` - The returned `Servers` array has information
    76    about the servers in the Raft peer configuration.
    77  
    78    - `ID` `(string)` - The ID of the server. This is the same as the `Address`
    79      but may be upgraded to a GUID in a future version of Nomad.
    80  
    81    - `Node` `(string)` - The node name of the server, as known to Nomad, or
    82      `"(unknown)"` if the node is stale and not known.
    83  
    84    - `Address` `(string)` - The `ip:port` for the server.
    85  
    86    - `Leader` `(bool)` - is either "true" or "false" depending on the server's
    87      role in the Raft configuration.
    88  
    89    - `Voter` `(bool)` - is "true" or "false", indicating if the server has a vote
    90      in the Raft configuration. Future versions of Nomad may add support for
    91      non-voting servers.
    92  
    93  ## Remove Raft Peer
    94  
    95  This endpoint removes a Nomad server with given address from the Raft
    96  configuration. The return code signifies success or failure.
    97  
    98  | Method   | Path                       | Produces                   |
    99  | -------- | ---------------------------| -------------------------- |
   100  | `DELETE` | `/v1/operator/raft/peer`   | `application/json`         |
   101  
   102  The table below shows this endpoint's support for
   103  [blocking queries](/api/index.html#blocking-queries) and
   104  [required ACLs](/api/index.html#acls).
   105  
   106  | Blocking Queries | ACL Required |
   107  | ---------------- | ------------ |
   108  | `NO`             | `management` |
   109  
   110  ### Parameters
   111  
   112  - `address` `(string: <optional>)` - Specifies the server to remove as
   113    `ip:port`. This cannot be provided along with the `id` parameter.
   114  
   115  - `id` `(string: <optional>)` - Specifies the server to remove as
   116    `id`. This cannot be provided along with the `address` parameter.
   117  
   118  ### Sample Request
   119  
   120  ```text
   121  $ curl \
   122      --request DELETE \
   123      https://localhost:4646/v1/operator/raft/peer?address=1.2.3.4
   124  ```
   125  
   126  ## Read Autopilot Configuration
   127  
   128  This endpoint retrieves its latest Autopilot configuration.
   129  
   130  | Method | Path                         | Produces                   |
   131  | ------ | ---------------------------- | -------------------------- |
   132  | `GET`  | `/operator/autopilot/configuration` | `application/json` |
   133  
   134  The table below shows this endpoint's support for
   135  [blocking queries](/api/index.html#blocking-queries),
   136  [consistency modes](/api/index.html#consistency-modes), and
   137  [required ACLs](/api/index.html#acls).
   138  
   139  | Blocking Queries | Consistency Modes | ACL Required    |
   140  | ---------------- | ----------------- | --------------- |
   141  | `NO`             | `none`            | `operator:read` |
   142  
   143  ### Sample Request
   144  
   145  ```text
   146  $ curl \
   147      https://localhost:4646/operator/autopilot/configuration
   148  ```
   149  
   150  ### Sample Response
   151  
   152  ```json
   153  {
   154    "CleanupDeadServers": true,
   155    "LastContactThreshold": "200ms",
   156    "MaxTrailingLogs": 250,
   157    "ServerStabilizationTime": "10s",
   158    "EnableRedundancyZones": false,
   159    "DisableUpgradeMigration": false,
   160    "EnableCustomUpgrades": false,
   161    "CreateIndex": 4,
   162    "ModifyIndex": 4
   163  }
   164  ```
   165  
   166  For more information about the Autopilot configuration options, see the
   167  [agent configuration section](/docs/configuration/autopilot.html).
   168  
   169  ## Update Autopilot Configuration
   170  
   171  This endpoint updates the Autopilot configuration of the cluster.
   172  
   173  | Method | Path                         | Produces                   |
   174  | ------ | ---------------------------- | -------------------------- |
   175  | `PUT`  | `/operator/autopilot/configuration` | `application/json` |
   176  
   177  The table below shows this endpoint's support for
   178  [blocking queries](/api/index.html#blocking-queries),
   179  [consistency modes](/api/index.html#consistency-modes), and
   180  [required ACLs](/api/index.html#acls).
   181  
   182  | Blocking Queries | Consistency Modes | ACL Required     |
   183  | ---------------- | ----------------- | ---------------- |
   184  | `NO`             | `none`            | `operator:write` |
   185  
   186  ### Parameters
   187  
   188  - `cas` `(int: 0)` - Specifies to use a Check-And-Set operation. The update will
   189    only happen if the given index matches the `ModifyIndex` of the configuration
   190    at the time of writing.
   191  
   192  ### Sample Payload
   193  
   194  ```json
   195  {
   196    "CleanupDeadServers": true,
   197    "LastContactThreshold": "200ms",
   198    "MaxTrailingLogs": 250,
   199    "ServerStabilizationTime": "10s",
   200    "EnableRedundancyZones": false,
   201    "DisableUpgradeMigration": false,
   202    "EnableCustomUpgrades": false,
   203    "CreateIndex": 4,
   204    "ModifyIndex": 4
   205  }
   206  ```
   207  
   208  - `CleanupDeadServers` `(bool: true)` - Specifies automatic removal of dead
   209    server nodes periodically and whenever a new server is added to the cluster.
   210  
   211  - `LastContactThreshold` `(string: "200ms")` - Specifies the maximum amount of
   212    time a server can go without contact from the leader before being considered
   213    unhealthy. Must be a duration value such as `10s`.
   214  
   215  - `MaxTrailingLogs` `(int: 250)` specifies the maximum number of log entries
   216    that a server can trail the leader by before being considered unhealthy.
   217  
   218  - `ServerStabilizationTime` `(string: "10s")` - Specifies the minimum amount of
   219    time a server must be stable in the 'healthy' state before being added to the
   220    cluster. Only takes effect if all servers are running Raft protocol version 3
   221    or higher. Must be a duration value such as `30s`.
   222  
   223  - `EnableRedundancyZones` `(bool: false)` - (Enterprise-only) Specifies whether 
   224    to enable redundancy zones.
   225  
   226  - `DisableUpgradeMigration` `(bool: false)` - (Enterprise-only) Disables Autopilot's
   227    upgrade migration strategy in Nomad Enterprise of waiting until enough
   228    newer-versioned servers have been added to the cluster before promoting any of
   229    them to voters.
   230  
   231  - `EnableCustomUpgrades` `(bool: false)` - (Enterprise-only) Specifies whether to 
   232    enable using custom upgrade versions when performing migrations.
   233  
   234  ## Read Health
   235  
   236  This endpoint queries the health of the autopilot status.
   237  
   238  | Method | Path                         | Produces                   |
   239  | ------ | ---------------------------- | -------------------------- |
   240  | `GET`  | `/operator/autopilot/health` | `application/json`         |
   241  
   242  The table below shows this endpoint's support for
   243  [blocking queries](/api/index.html#blocking-queries),
   244  [consistency modes](/api/index.html#consistency-modes), and
   245  [required ACLs](/api/index.html#acls).
   246  
   247  | Blocking Queries | Consistency Modes | ACL Required    |
   248  | ---------------- | ----------------- | --------------- |
   249  | `NO`             | `none`            | `operator:read` |
   250  
   251  ### Sample Request
   252  
   253  ```text
   254  $ curl \
   255      https://localhost:4646/v1/operator/autopilot/health
   256  ```
   257  
   258  ### Sample response
   259  
   260  ```json
   261  {
   262    "Healthy": true,
   263    "FailureTolerance": 0,
   264    "Servers": [
   265      {
   266        "ID": "e349749b-3303-3ddf-959c-b5885a0e1f6e",
   267        "Name": "node1",
   268        "Address": "127.0.0.1:8300",
   269        "SerfStatus": "alive",
   270        "Version": "0.8.0",
   271        "Leader": true,
   272        "LastContact": "0s",
   273        "LastTerm": 2,
   274        "LastIndex": 46,
   275        "Healthy": true,
   276        "Voter": true,
   277        "StableSince": "2017-03-06T22:07:51Z"
   278      },
   279      {
   280        "ID": "e36ee410-cc3c-0a0c-c724-63817ab30303",
   281        "Name": "node2",
   282        "Address": "127.0.0.1:8205",
   283        "SerfStatus": "alive",
   284        "Version": "0.8.0",
   285        "Leader": false,
   286        "LastContact": "27.291304ms",
   287        "LastTerm": 2,
   288        "LastIndex": 46,
   289        "Healthy": true,
   290        "Voter": false,
   291        "StableSince": "2017-03-06T22:18:26Z"
   292      }
   293    ]
   294  }
   295  ```
   296  
   297  - `Healthy` is whether all the servers are currently healthy.
   298  
   299  - `FailureTolerance` is the number of redundant healthy servers that could be
   300    fail without causing an outage (this would be 2 in a healthy cluster of 5
   301    servers).
   302  
   303  - `Servers` holds detailed health information on each server:
   304  
   305    - `ID` is the Raft ID of the server.
   306  
   307    - `Name` is the node name of the server.
   308  
   309    - `Address` is the address of the server.
   310  
   311    - `SerfStatus` is the SerfHealth check status for the server.
   312  
   313    - `Version` is the Nomad version of the server.
   314  
   315    - `Leader` is whether this server is currently the leader.
   316  
   317    - `LastContact` is the time elapsed since this server's last contact with the leader.
   318  
   319    - `LastTerm` is the server's last known Raft leader term.
   320  
   321    - `LastIndex` is the index of the server's last committed Raft log entry.
   322  
   323    - `Healthy` is whether the server is healthy according to the current Autopilot configuration.
   324  
   325    - `Voter` is whether the server is a voting member of the Raft cluster.
   326  
   327    - `StableSince` is the time this server has been in its current `Healthy` state.
   328  
   329    The HTTP status code will indicate the health of the cluster. If `Healthy` is true, then a
   330    status of 200 will be returned. If `Healthy` is false, then a status of 429 will be returned.