github.com/ranjib/nomad@v0.1.1-0.20160225204057-97751b02f70b/website/source/docs/agent/config.html.md (about) 1 --- 2 layout: "docs" 3 page_title: "Configuration" 4 sidebar_current: "docs-agent-config" 5 description: |- 6 Learn about the configuration options available for the Nomad agent. 7 --- 8 9 # Configuration 10 11 Nomad agents have a variety of options that can be specified via configuration 12 files or command-line flags. Config files must be written in 13 [HCL](https://github.com/hashicorp/hcl) or JSON syntax. Nomad can read and 14 combine options from multiple configuration files or directories to configure 15 the Nomad agent. 16 17 ## Loading Configuration Files 18 19 When specifying multiple config file options on the command-line, the files are 20 loaded in the order they are specified. For example: 21 22 nomad agent -config server.conf /etc/nomad extra.json 23 24 Will load configuration from `server.conf`, from `.hcl` and `.json` files under 25 `/etc/nomad`, and finally from `extra.json`. 26 27 Configuration files in directories are loaded alphabetically. With the 28 directory option, only files ending with the `.hcl` or `.json` extensions are 29 used. Directories are not loaded recursively. 30 31 As each file is processed, its contents are merged into the existing 32 configuration. When merging, any non-empty values from the latest config file 33 will append or replace options in the current configuration. An empty value 34 means `""` for strings, `0` for integer or float values, and `false` for 35 booleans. Since empty values are ignored you cannot disable an option like 36 server mode once you've enabled it. 37 38 Complex data types like arrays or maps are usually merged. [Some configuration 39 options](#cli) can also be specified using the command-line interface. Please 40 refer to the sections below for the details of each option. 41 42 ## Configuration Syntax 43 44 The preferred configuration syntax is HCL, which supports comments, but you can 45 also use JSON. Below is an example configuration file in HCL syntax. 46 47 ``` 48 bind_addr = "0.0.0.0" 49 data_dir = "/var/lib/nomad" 50 51 advertise { 52 # We need to specify our host's IP because we can't 53 # advertise 0.0.0.0 to other nodes in our cluster. 54 rpc = "1.2.3.4:4647" 55 } 56 57 server { 58 enabled = true 59 bootstrap_expect = 3 60 } 61 62 client { 63 enabled = true 64 network_speed = 10 65 } 66 67 atlas { 68 infrastructure = "hashicorp/mars" 69 token = "atlas.v1.AFE84330943" 70 } 71 ``` 72 73 Note that it is strongly recommended _not_ to operate a node as both `client` 74 and `server`, although this is supported to simplify development and testing. 75 76 ## General Options 77 78 The following configuration options are available to both client and server 79 nodes, unless otherwise specified: 80 81 * <a id="region">`region`</a>: Specifies the region the Nomad agent is a 82 member of. A region typically maps to a geographic region, for example `us`, 83 with potentially multiple zones, which map to [datacenters](#datacenter) such 84 as `us-west` and `us-east`. Defaults to `global`. 85 86 * `datacenter`: Datacenter of the local agent. All members of a datacenter 87 should share a local LAN connection. Defaults to `dc1`. 88 89 * <a id="name">`name`</a>: The name of the local node. This value is used to 90 identify individual nodes in a given datacenter and must be unique 91 per-datacenter. By default this is set to the local host's name. 92 93 * `data_dir`: A local directory used to store agent state. Client nodes use this 94 directory by default to store temporary allocation data as well as cluster 95 information. Server nodes use this directory to store cluster state, including 96 the replicated log and snapshot data. This option is required to start the 97 Nomad agent and must be specified as an absolute path. 98 99 * `log_level`: Controls the verbosity of logs the Nomad agent will output. Valid 100 log levels include `WARN`, `INFO`, or `DEBUG` in increasing order of 101 verbosity. Defaults to `INFO`. 102 103 * <a id="bind_addr">`bind_addr`</a>: Used to indicate which address the Nomad 104 agent should bind to for network services, including the HTTP interface as 105 well as the internal gossip protocol and RPC mechanism. This should be 106 specified in IP format, and can be used to easily bind all network services to 107 the same address. It is also possible to bind the individual services to 108 different addresses using the [addresses](#addresses) configuration option. 109 Defaults to the local loopback address `127.0.0.1`. 110 111 * `enable_debug`: Enables the debugging HTTP endpoints. These endpoints can be 112 used with profiling tools to dump diagnostic information about Nomad's 113 internals. It is not recommended to leave this enabled in production 114 environments. Defaults to `false`. 115 116 * `ports`: Controls the network ports used for different services required by 117 the Nomad agent. The value is a key/value mapping of port numbers, and accepts 118 the following keys: 119 <br> 120 * `http`: The port used to run the HTTP server. Applies to both client and 121 server nodes. Defaults to `4646`. 122 * `rpc`: The port used for internal RPC communication between agents and 123 servers, and for inter-server traffic for the consensus algorithm (raft). 124 Defaults to `4647`. Only used on server nodes. 125 * `serf`: The port used for the gossip protocol for cluster membership. Both 126 TCP and UDP should be routable between the server nodes on this port. 127 Defaults to `4648`. Only used on server nodes. 128 129 * <a id="addresses">`addresses`</a>: Controls the bind address for individual 130 network services. Any values configured in this block take precedence over the 131 default [bind_addr](#bind_addr). The value is a map of IP addresses and 132 supports the following keys: 133 <br> 134 * `http`: The address the HTTP server is bound to. This is the most common 135 bind address to change. Applies to both clients and servers. 136 * `rpc`: The address to bind the internal RPC interfaces to. Should be exposed 137 only to other cluster members if possible. Used only on server nodes, but 138 must be accessible from all agents. 139 * `serf`: The address used to bind the gossip layer to. Both a TCP and UDP 140 listener will be exposed on this address. Should be restricted to only 141 server nodes from the same datacenter if possible. Used only on server 142 nodes. 143 144 * `advertise`: Controls the advertise address for individual network services. 145 This can be used to advertise a different address to the peers of a server 146 node to support more complex network configurations such as NAT. This 147 configuration is optional, and defaults to the bind address of the specific 148 network service if it is not provided. This configuration is only applicable 149 on server nodes. The value is a map of IP addresses and ports and supports 150 the following keys: 151 <br> 152 * `rpc`: The address to advertise for the RPC interface. This address should 153 be reachable by all of the agents in the cluster. For example: 154 ``` 155 advertise { 156 rpc = "1.2.3.4:4647" 157 } 158 ``` 159 * `serf`: The address advertised for the gossip layer. This address must be 160 reachable from all server nodes. It is not required that clients can reach 161 this address. 162 163 * `telemetry`: Used to control how the Nomad agent exposes telemetry data to 164 external metrics collection servers. This is a key/value mapping and supports 165 the following keys: 166 <br> 167 * `statsite_address`: Address of a 168 [statsite](https://github.com/armon/statsite) server to forward metrics data 169 to. 170 * `statsd_address`: Address of a [statsd](https://github.com/etsy/statsd) 171 server to forward metrics to. 172 * `disable_hostname`: A boolean indicating if gauge values should not be 173 prefixed with the local hostname. 174 175 * `leave_on_interrupt`: Enables gracefully leaving when receiving the 176 interrupt signal. By default, the agent will exit forcefully on any signal. 177 178 * `leave_on_terminate`: Enables gracefully leaving when receiving the 179 terminate signal. By default, the agent will exit forcefully on any signal. 180 181 * `enable_syslog`: Enables logging to syslog. This option only works on 182 Unix based systems. 183 184 * `syslog_facility`: Controls the syslog facility that is used. By default, 185 `LOCAL0` will be used. This should be used with `enable_syslog`. 186 187 * `disable_update_check`: Disables automatic checking for security bulletins 188 and new version releases. 189 190 * `disable_anonymous_signature`: Disables providing an anonymous signature 191 for de-duplication with the update check. See `disable_update_check`. 192 193 * `http_api_response_headers`: This object allows adding headers to the 194 HTTP API responses. For example, the following config can be used to enable 195 CORS on the HTTP API endpoints: 196 ``` 197 http_api_response_headers { 198 Access-Control-Allow-Origin = "*" 199 } 200 ``` 201 202 ## Server-specific Options 203 204 The following options are applicable to server agents only and need not be 205 configured on client nodes. 206 207 * `server`: This is the top-level key used to define the Nomad server 208 configuration. It is a key/value mapping which supports the following keys: 209 <br> 210 * `enabled`: A boolean indicating if server mode should be enabled for the 211 local agent. All other server options depend on this value being set. 212 Defaults to `false`. 213 * <a id="bootstrap_expect">`bootstrap_expect`</a>: This is an integer 214 representing the number of server nodes to wait for before bootstrapping. It 215 is most common to use the odd-numbered integers `3` or `5` for this value, 216 depending on the cluster size. A value of `1` does not provide any fault 217 tolerance and is not recommended for production use cases. 218 * `data_dir`: This is the data directory used for server-specific data, 219 including the replicated log. By default, this directory lives inside of the 220 [data_dir](#data_dir) in the "server" sub-path. 221 * `protocol_version`: The Nomad protocol version spoken when communicating 222 with other Nomad servers. This value is typically not required as the agent 223 internally knows the latest version, but may be useful in some upgrade 224 scenarios. 225 * `num_schedulers`: The number of parallel scheduler threads to run. This 226 can be as many as one per core, or `0` to disallow this server from making 227 any scheduling decisions. This defaults to the number of CPU cores. 228 * `enabled_schedulers`: This is an array of strings indicating which 229 sub-schedulers this server will handle. This can be used to restrict the 230 evaluations that worker threads will dequeue for processing. This 231 defaults to all available schedulers. 232 * `node_gc_threshold` This is a string with a unit suffix, such as "300ms", 233 "1.5h" or "25m". Valid time units are "ns", "us" (or "µs"), "ms", "s", 234 "m", "h". Controls how long a node must be in a terminal state before it is 235 garbage collected and purged from the system. 236 * <a id="rejoin_after_leave">`rejoin_after_leave`</a> When provided, Nomad will ignore a previous leave and 237 attempt to rejoin the cluster when starting. By default, Nomad treats leave 238 as a permanent intent and does not attempt to join the cluster again when 239 starting. This flag allows the previous state to be used to rejoin the 240 cluster. 241 * <a id="retry_join">`retry_join`</a> Similar to [`start_join`](#start_join) but allows retrying a join 242 if the first attempt fails. This is useful for cases where we know the 243 address will become available eventually. 244 * <a id="retry_interval">`retry_interval`</a> The time to wait between join attempts. Defaults to 30s. 245 * <a id="retry_max">`retry_max`</a> The maximum number of join attempts to be made before exiting 246 with a return code of 1. By default, this is set to 0 which is interpreted 247 as infinite retries. 248 * <a id="start_join">`start_join`</a> An array of strings specifying addresses of nodes to join upon startup. 249 If Nomad is unable to join with any of the specified addresses, agent startup will 250 fail. By default, the agent won't join any nodes when it starts up. 251 252 ## Client-specific Options 253 254 The following options are applicable to client agents only and need not be 255 configured on server nodes. 256 257 * `client`: This is the top-level key used to define the Nomad client 258 configuration. Like the server configuration, it is a key/value mapping which 259 supports the following keys: 260 <br> 261 * `enabled`: A boolean indicating if client mode is enabled. All other client 262 configuration options depend on this value. Defaults to `false`. 263 * <a id="state_dir">`state_dir`</a>: This is the state dir used to store 264 client state. By default, it lives inside of the [data_dir](#data_dir), in 265 the "client" sub-path. It must be specified as an absolute path. 266 * <a id="alloc_dir">`alloc_dir`</a>: A directory used to store allocation data. 267 Depending on the workload, the size of this directory can grow arbitrarily 268 large as it is used to store downloaded artifacts for drivers (QEMU images, 269 JAR files, etc.). It is therefore important to ensure this directory is 270 placed some place on the filesystem with adequate storage capacity. By 271 default, this directory lives under the [data_dir](#data_dir) at the 272 "alloc" sub-path. It must be specified as an absolute path. 273 * <a id="servers">`servers`</a>: An array of server addresses. This list is 274 used to register the client with the server nodes and advertise the 275 available resources so that the agent can receive work. If a port is not specified 276 in the array of server addresses, the default port `4647` will be used. 277 * <a id="node_id">`node_id`</a>: This is the value used to uniquely identify 278 the local agent's node registration with the servers. This can be any 279 arbitrary string but must be unique to the cluster. By default, if not 280 specified, a randomly- generate UUID will be used. 281 * <a id="node_class">`node_class`</a>: A string used to logically group client 282 nodes by class. This can be used during job placement as a filter. This 283 option is not required and has no default. 284 * <a id="meta">`meta`</a>: This is a key/value mapping of metadata pairs. This 285 is a free-form map and can contain any string values. 286 * <a id="options">`options`</a>: This is a key/value mapping of internal 287 configuration for clients, such as for driver configuration. Please see 288 [here](#options_map) for a description of available options. 289 * <a id="network_interface">`network_interface`</a>: This is a string to force 290 network fingerprinting to use a specific network interface 291 * <a id="network_speed">`network_speed`</a>: This is an int that sets the 292 default link speed of network interfaces, in megabits, if their speed can 293 not be determined dynamically. 294 * `max_kill_timeout`: `max_kill_timeout` is a time duration that can be 295 specified using the `s`, `m`, and `h` suffixes, such as `30s`. If a job's 296 task specifies a `kill_timeout` greater than `max_kill_timeout`, 297 `max_kill_timeout` is used. This is to prevent a user being able to set an 298 unreasonable timeout. If unset, a default is used. 299 300 ### Client Options Map <a id="options_map"></a> 301 302 The following is not an exhaustive list of options that can be passed to the 303 Client, but rather the set of options that configure the Client and not the 304 drivers. To find the options supported by an individual driver, see the drivers 305 documentation [here](/docs/drivers/index.html) 306 307 * `consul.address`: The address to the local Consul agent given in the format of 308 `host:port`. The default is the same as the Consul default address, 309 `127.0.0.1:8500`. 310 311 * `consul.token`: Token is used to provide a per-request ACL token.This options 312 overrides the agent's default token 313 314 * `consul.auth`: The auth information to use for http access to the Consul 315 Agent. 316 317 * `consul.ssl`: This boolean option sets the transport scheme to talk to the Consul 318 Agent as `https`. This option is unset by default and so the default transport 319 scheme for the consul api client is `http`. 320 321 * `consul.verifyssl`: This option enables SSL verification when the transport 322 scheme for the Consul API client is `https`. This is set to true by default. 323 324 * `driver.whitelist`: A comma seperated list of whitelisted drivers (e.g. 325 "docker,qemu"). If specified, drivers not in the whitelist will be disabled. 326 If the whitelist is empty, all drivers are fingerprinted and enabled where 327 applicable. 328 329 * `fingerprint.whitelist`: A comma seperated list of whitelisted fingerprinters. 330 If specified, fingerprinters not in the whitelist will be disabled. If the 331 whitelist is empty, all fingerprinters are used. 332 333 ## Atlas Options 334 335 **NOTE**: Nomad integration with Atlas is awaiting release of Atlas features 336 for Nomad support. Nomad currently only validates configuration options for 337 Atlas but does not use them. 338 See [#183](https://github.com/hashicorp/nomad/issues/183) for more details. 339 340 The following options are used to configure [Atlas](https://atlas.hashicorp.com) 341 integration and are entirely optional. 342 343 * `atlas`: The top-level config key used to contain all Atlas-related 344 configuration options. The value is a key/value map which supports the 345 following keys: 346 <br> 347 * <a id="infrastructure">`infrastructure`</a>: The Atlas infrastructure name to 348 connect this agent to. This value should be of the form 349 `<org>/<infrastructure>`, and requires a valid [token](#token) authorized on 350 the infrastructure. 351 * <a id="token">`token`</a>: The Atlas token to use for authentication. This 352 token should have access to the provided [infrastructure](#infrastructure). 353 * <a id="join">`join`</a>: A boolean indicating if the auto-join feature of 354 Atlas should be enabled. Defaults to `false`. 355 * `endpoint`: The address of the Atlas instance to connect to. Defaults to the 356 public Atlas endpoint and is only used if both 357 [infrastructure](#infrastructure) and [token](#token) are provided. 358 359 ## Command-line Options <a id="cli"></a> 360 361 A subset of the available Nomad agent configuration can optionally be passed in 362 via CLI arguments. The `agent` command accepts the following arguments: 363 364 * `alloc-dir=<path>`: Equivalent to the Client [alloc_dir](#alloc_dir) config 365 option. 366 * `-atlas=<infrastructure>`: Equivalent to the Atlas 367 [infrastructure](#infrastructure) config option. 368 * `-atlas-join`: Equivalent to the Atlas [join](#join) config option. 369 * `-atlas-token=<token>`: Equivalent to the Atlas [token](#token) config option. 370 * `-bind=<address>`: Equivalent to the [bind_addr](#bind_addr) config option. 371 * `-bootstrap-expect=<num>`: Equivalent to the 372 [bootstrap_expect](#bootstrap_expect) config option. 373 * `-client`: Enable client mode on the local agent. 374 * `-config=<path>`: Specifies the path to a configuration file or a directory of 375 configuration files to load. Can be specified multiple times. 376 * `-data-dir=<path>`: Equivalent to the [data_dir](#data_dir) config option. 377 * `-dc=<datacenter>`: Equivalent to the [datacenter](#datacenter) config option. 378 * `-dev`: Start the agent in development mode. This enables a pre-configured 379 dual-role agent (client + server) which is useful for developing or testing 380 Nomad. No other configuration is required to start the agent in this mode. 381 * `-join=<address>`: Address of another agent to join upon starting up. This can 382 be specified multiple times to specify multiple agents to join. 383 * `-log-level=<level>`: Equivalent to the [log_level](#log_level) config option. 384 * `-meta=<key=value>`: Equivalent to the Client [meta](#meta) config option. 385 * `-network-interface<interface>`: Equivalent to the Client 386 [network_interface](#network_interface) config option. 387 * `-network-speed<MBits>`: Equivalent to the Client 388 [network_speed](#network_speed) config option. 389 * `-node=<name>`: Equivalent to the [name](#name) config option. 390 * `-node-class=<class>`: Equivalent to the Client [node_class](#node_class) 391 config option. 392 * `-node-id=<uuid>`: Equivalent to the Client [node_id](#node_id) config option. 393 * `-region=<region>`: Equivalent to the [region](#region) config option. 394 * `-rejoin`: Equivalent to the [rejoin_after_leave](#rejoin_after_leave) config option. 395 * `-retry-interval`: Equivalent to the [retry_interval](#retry_interval) config option. 396 * `-retry-join`: Similar to `-join` but allows retrying a join if the first attempt fails. 397 * `-retry-max`: Similar to the [retry_max](#retry_max) config option. 398 * `-server`: Enable server mode on the local agent. 399 * `-servers=<host:port>`: Equivalent to the Client [servers](#servers) config 400 option. 401 * `-state-dir=<path>`: Equivalent to the Client [state_dir](#state_dir) config 402 option.