github.com/iqoqo/nomad@v0.11.3-0.20200911112621-d7021c74d101/website/pages/docs/configuration/index.mdx (about) 1 --- 2 layout: docs 3 page_title: Agent Configuration 4 sidebar_title: Configuration 5 description: Learn about the configuration options available for the Nomad agent. 6 --- 7 8 # Nomad Configuration 9 10 Nomad agents have a variety of parameters that can be specified via 11 configuration files or command-line flags. Configuration files are written in 12 [HCL][hcl]. Nomad can read and combine parameters from multiple configuration 13 files or directories to configure the Nomad agent. 14 15 ## Load Order and Merging 16 17 The Nomad agent supports multiple configuration files, which can be provided 18 using the `-config` CLI flag. The flag can accept either a file or folder. In 19 the case of a folder, any `.hcl` and `.json` files in the folder will be loaded 20 and merged in lexicographical order. Directories are not loaded recursively. 21 22 For example: 23 24 ```shell-sessionnomad agent -config=server.conf -config=/etc/nomad -config=extra.json 25 26 ``` 27 28 This will load configuration from `server.conf`, from `.hcl` and `.json` files 29 under `/etc/nomad`, and finally from `extra.json`. 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 parameters 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 a parameter like 36 `server` mode once you've enabled it. 37 38 Here is an example Nomad agent configuration that runs in both client and server 39 mode. 40 41 ```hcl 42 data_dir = "/var/lib/nomad" 43 44 bind_addr = "0.0.0.0" # the default 45 46 advertise { 47 # Defaults to the first private IP address. 48 http = "1.2.3.4" 49 rpc = "1.2.3.4" 50 serf = "1.2.3.4:5648" # non-default ports may be specified 51 } 52 53 server { 54 enabled = true 55 bootstrap_expect = 3 56 } 57 58 client { 59 enabled = true 60 network_speed = 10 61 } 62 63 plugin "raw_exec" { 64 config { 65 enabled = true 66 } 67 } 68 69 consul { 70 address = "1.2.3.4:8500" 71 } 72 73 ``` 74 75 ~> Note that it is strongly recommended **not** to operate a node as both 76 `client` and `server`, although this is supported to simplify development and 77 testing. 78 79 ## General Parameters 80 81 - `acl` `(`[`ACL`]`: nil)` - Specifies configuration which is specific to ACLs. 82 83 - `addresses` `(Addresses: see below)` - Specifies the bind address for 84 individual network services. Any values configured in this stanza take 85 precedence over the default [bind_addr](#bind_addr). 86 The values support [go-sockaddr/template format][go-sockaddr/template]. 87 88 - `http` - The address the HTTP server is bound to. This is the most common 89 bind address to change. 90 91 - `rpc` - The address to bind the internal RPC interfaces to. Should be 92 exposed only to other cluster members if possible. 93 94 - `serf` - The address used to bind the gossip layer to. Both a TCP and UDP 95 listener will be exposed on this address. Should be exposed only to other 96 cluster members if possible. 97 98 - `advertise` `(Advertise: see below)` - Specifies the advertise address for 99 individual network services. This can be used to advertise a different address 100 to the peers of a server or a client node to support more complex network 101 configurations such as NAT. This configuration is optional, and defaults to 102 the bind address of the specific network service if it is not provided. Any 103 values configured in this stanza take precedence over the default 104 [bind_addr](#bind_addr). 105 106 If the bind address is `0.0.0.0` then the address 107 private IP found is advertised. You may advertise an alternate port as well. 108 The values support [go-sockaddr/template format][go-sockaddr/template]. 109 110 - `http` - The address to advertise for the HTTP interface. This should be 111 reachable by all the nodes from which end users are going to use the Nomad 112 CLI tools. 113 114 - `rpc` - The address advertised to Nomad client nodes. This allows 115 advertising a different RPC address than is used by Nomad Servers such that 116 the clients can connect to the Nomad servers if they are behind a NAT. 117 118 - `serf` - The address advertised for the gossip layer. This address must be 119 reachable from all server nodes. It is not required that clients can reach 120 this address. Nomad servers will communicate to each other over RPC using 121 the advertised Serf IP and advertised RPC Port. 122 123 - `audit` `(`[`Audit`]`: nil)` - Enterprise-only. Specifies audit logging 124 configuration. 125 126 - `bind_addr` `(string: "0.0.0.0")` - Specifies which address the Nomad 127 agent should bind to for network services, including the HTTP interface as 128 well as the internal gossip protocol and RPC mechanism. This should be 129 specified in IP format, and can be used to easily bind all network services to 130 the same address. It is also possible to bind the individual services to 131 different addresses using the [addresses](#addresses) configuration option. 132 Dev mode (`-dev`) defaults to localhost. 133 The value supports [go-sockaddr/template format][go-sockaddr/template]. 134 135 - `client` `(`[`Client`]`: nil)` - Specifies configuration which is specific 136 to the Nomad client. 137 138 - `consul` `(`[`Consul`]`: nil)` - Specifies configuration for 139 connecting to Consul. 140 141 - `datacenter` `(string: "dc1")` - Specifies the data center of the local agent. 142 All members of a datacenter should share a local LAN connection. 143 144 - `data_dir` `(string: required)` - Specifies a local directory used to store 145 agent state. Client nodes use this directory by default to store temporary 146 allocation data as well as cluster information. Server nodes use this 147 directory to store cluster state, including the replicated log and snapshot 148 data. This must be specified as an absolute path. 149 150 ~> **WARNING**: This directory **must not** be set to a directory that is 151 [included in the chroot](/docs/drivers/exec#chroot) if you use the 152 [`exec`](/docs/drivers/exec) driver. 153 154 - `disable_anonymous_signature` `(bool: false)` - Specifies if Nomad should 155 provide an anonymous signature for de-duplication with the update check. 156 157 - `disable_update_check` `(bool: false)` - Specifies if Nomad should not check 158 for updates and security bulletins. 159 160 - `enable_debug` `(bool: false)` - Specifies if the debugging HTTP endpoints 161 should be enabled. These endpoints can be used with profiling tools to dump 162 diagnostic information about Nomad's internals. 163 164 - `enable_syslog` `(bool: false)` - Specifies if the agent should log to syslog. 165 This option only works on Unix based systems. 166 167 - `http_api_response_headers` `(map<string|string>: nil)` - Specifies 168 user-defined headers to add to the HTTP API responses. 169 170 - `leave_on_interrupt` `(bool: false)` - Specifies if the agent should 171 gracefully leave when receiving the interrupt signal. By default, the agent 172 will exit forcefully on any signal. This value should only be set to true on 173 server agents if it is expected that a terminated server instance will never 174 join the cluster again. 175 176 - `leave_on_terminate` `(bool: false)` - Specifies if the agent should 177 gracefully leave when receiving the terminate signal. By default, the agent 178 will exit forcefully on any signal. This value should only be set to true on 179 server agents if it is expected that a terminated server instance will never 180 join the cluster again. 181 182 - `limits` - Available in Nomad 0.10.3 and later, this is a nested object that 183 configures limits that are enforced by the agent. The following parameters 184 are available: 185 186 - `https_handshake_timeout` `(string: "5s")` - Configures the limit for how 187 long the HTTPS server in both client and server agents will wait for a 188 client to complete a TLS handshake. This should be kept conservative as it 189 limits how many connections an unauthenticated attacker can open if 190 [`tls.http = true`][tls] is being used (strongly recommended in 191 production). Default value is `5s`. `0` disables HTTP handshake timeouts. 192 193 - `http_max_conns_per_client` `(int: 100)` - Configures a limit of how many 194 concurrent TCP connections a single client IP address is allowed to open to 195 the agent's HTTP server. This affects the HTTP servers in both client and 196 server agents. Default value is `100`. `0` disables HTTP connection limits. 197 198 - `rpc_handshake_timeout` `(string: "5s")` - Configures the limit for how 199 long servers will wait after a client TCP connection is established before 200 they complete the connection handshake. When TLS is used, the same timeout 201 applies to the TLS handshake separately from the initial protocol 202 negotiation. All Nomad clients should perform this immediately on 203 establishing a new connection. This should be kept conservative as it 204 limits how many connections an unauthenticated attacker can open if 205 TLS is being using to authenticate clients (strongly recommended in 206 production). When `tls.rpc` is true on servers, this limits how long the 207 connection and associated goroutines will be held open before the client 208 successfully authenticates. Default value is `5s`. `0` disables RPC handshake 209 timeouts. 210 211 - `rpc_max_conns_per_client` `(int: 100)` - Configures a limit of how 212 many concurrent TCP connections a single source IP address is allowed 213 to open to a single server. Client agents do not accept RPC TCP connections 214 directly and therefore are not affected. It affects both clients connections 215 and other server connections. Nomad clients multiplex many RPC calls over a 216 single TCP connection, except for streaming endpoints such as [log 217 streaming][log-api] which require their own connection when routed through 218 servers. A server needs at least 2 TCP connections (1 Raft, 1 RPC) per peer 219 server locally and in any federated region. Servers also need a TCP connection 220 per routed streaming endpoint concurrently in use. Only operators use streaming 221 endpoints; as of 0.10.3 Nomad client code does not. A reasonably low limit 222 significantly reduces the ability of an unauthenticated attacker to consume 223 unbounded resources by holding open many connections. You may need to 224 increase this if WAN federated servers connect via proxies or NAT gateways 225 or similar causing many legitimate connections from a single source IP. 226 Default value is `100` which is designed to support the majority of users. 227 `0` disables RPC connection limits. `26` is the minimum as `20` connections 228 are always reserved for non-streaming connections (Raft and RPC) to ensure 229 streaming RPCs do not prevent normal server operation. This minimum may be 230 lowered in the future when streaming RPCs no longer require their own TCP 231 connection. 232 233 - `log_level` `(string: "INFO")` - Specifies the verbosity of logs the Nomad 234 agent will output. Valid log levels include `WARN`, `INFO`, or `DEBUG` in 235 increasing order of verbosity. 236 237 - `log_json` `(bool: false)` - Output logs in a JSON format. 238 239 - `log_file` `(string: "")` - Specifies the path for logging. If the path 240 does not includes a filename, the filename defaults to "nomad-{timestamp}.log". 241 This setting can be combined with `log_rotate_bytes` and `log_rotate_duration` 242 for a fine-grained log rotation control. 243 244 - `log_rotate_bytes` `(int: 0)` - Specifies the number of bytes that should be 245 written to a log before it needs to be rotated. Unless specified, there is no 246 limit to the number of bytes that can be written to a log file. 247 248 - `log_rotate_duration` `(duration: "24h")` - Specifies the maximum duration a 249 log should be written to before it needs to be rotated. Must be a duration 250 value such as 30s. 251 252 - `log_rotate_max_files` `(int: 0)` - Specifies the maximum number of older log 253 file archives to keep. If 0 no files are ever deleted. 254 255 - `name` `(string: [hostname])` - Specifies the name of the local node. This 256 value is used to identify individual agents. When specified on a server, the 257 name must be unique within the region. 258 259 - `plugin_dir` `(string: "[data_dir]/plugins")` - Specifies the directory to 260 use for looking up plugins. By default, this is the top-level 261 [data_dir](#data_dir) suffixed with "plugins", like `"/opt/nomad/plugins"`. 262 This must be an absolute path. 263 264 - `plugin` `(`[`Plugin`]`: nil)` - Specifies configuration for a 265 specific plugin. The plugin stanza may be repeated, once for each plugin being 266 configured. The key of the stanza is the plugin's executable name relative to 267 the [plugin_dir](#plugin_dir). 268 269 - `ports` `(Port: see below)` - Specifies the network ports used for different 270 services required by the Nomad agent. 271 272 - `http` - The port used to run the HTTP server. 273 274 - `rpc` - The port used for internal RPC communication between 275 agents and servers, and for inter-server traffic for the consensus algorithm 276 (raft). 277 278 - `serf` - The port used for the gossip protocol for cluster 279 membership. Both TCP and UDP should be routable between the server nodes on 280 this port. 281 282 The default values are: 283 284 ```hcl 285 ports { 286 http = 4646 287 rpc = 4647 288 serf = 4648 289 } 290 ``` 291 292 - `region` `(string: "global")` - Specifies the region the Nomad agent is a 293 member of. A region typically maps to a geographic region, for example `us`, 294 with potentially multiple zones, which map to [datacenters](#datacenter) such 295 as `us-west` and `us-east`. 296 297 - `sentinel` `(`[`Sentinel`]`: nil)` - Specifies configuration for Sentinel 298 policies. 299 300 - `server` `(`[`Server`]`: nil)` - Specifies configuration which is specific 301 to the Nomad server. 302 303 - `syslog_facility` `(string: "LOCAL0")` - Specifies the syslog facility to 304 write to. This has no effect unless `enable_syslog` is true. 305 306 - `tls` `(`[`TLS`][tls]`: nil)` - Specifies configuration for TLS. 307 308 - `vault` `(`[`Vault`]`: nil)` - Specifies configuration for 309 connecting to Vault. 310 311 ## Examples 312 313 ### Custom Region and Datacenter 314 315 This example shows configuring a custom region and data center for the Nomad 316 agent: 317 318 ```hcl 319 region = "europe" 320 datacenter = "ams" 321 ``` 322 323 ### Enable CORS 324 325 This example shows how to enable CORS on the HTTP API endpoints: 326 327 ```hcl 328 http_api_response_headers { 329 "Access-Control-Allow-Origin" = "*" 330 } 331 ``` 332 333 [`acl`]: /docs/configuration/acl 'Nomad Agent ACL Configuration' 334 [`audit`]: /docs/configuration/audit 'Nomad Agent Audit Logging Configuration' 335 [`client`]: /docs/configuration/client 'Nomad Agent client Configuration' 336 [`consul`]: /docs/configuration/consul 'Nomad Agent consul Configuration' 337 [`plugin`]: /docs/configuration/plugin 'Nomad Agent Plugin Configuration' 338 [`sentinel`]: /docs/configuration/sentinel 'Nomad Agent sentinel Configuration' 339 [`server`]: /docs/configuration/server 'Nomad Agent server Configuration' 340 [tls]: /docs/configuration/tls 'Nomad Agent tls Configuration' 341 [`vault`]: /docs/configuration/vault 'Nomad Agent vault Configuration' 342 [go-sockaddr/template]: https://godoc.org/github.com/hashicorp/go-sockaddr/template 343 [log-api]: /api-docs/client#stream-logs 344 [hcl]: https://github.com/hashicorp/hcl 'HashiCorp Configuration Language'