github.com/Ilhicas/nomad@v1.0.4-0.20210304152020-e86851182bc3/website/content/docs/configuration/client.mdx (about) 1 --- 2 layout: docs 3 page_title: client Stanza - Agent Configuration 4 sidebar_title: client 5 description: |- 6 The "client" stanza configures the Nomad agent to accept jobs as assigned by 7 the Nomad server, join the cluster, and specify driver-specific configuration. 8 --- 9 10 # `client` Stanza 11 12 <Placement groups={['client']} /> 13 14 The `client` stanza configures the Nomad agent to accept jobs as assigned by 15 the Nomad server, join the cluster, and specify driver-specific configuration. 16 17 ```hcl 18 client { 19 enabled = true 20 servers = ["1.2.3.4:4647", "5.6.7.8:4647"] 21 } 22 ``` 23 24 ## `client` Parameters 25 26 - `alloc_dir` `(string: "[data_dir]/alloc")` - Specifies the directory to use 27 for allocation data. By default, this is the top-level 28 [data_dir](/docs/configuration#data_dir) suffixed with 29 "alloc", like `"/opt/nomad/alloc"`. This must be an absolute path. 30 31 - `chroot_env` <code>([ChrootEnv](#chroot_env-parameters): nil)</code> - 32 Specifies a key-value mapping that defines the chroot environment for jobs 33 using the Exec and Java drivers. 34 35 - `enabled` `(bool: false)` - Specifies if client mode is enabled. All other 36 client configuration options depend on this value. 37 38 - `max_kill_timeout` `(string: "30s")` - Specifies the maximum amount of time a 39 job is allowed to wait to exit. Individual jobs may customize their own kill 40 timeout, but it may not exceed this value. 41 42 - `disable_remote_exec` `(bool: false)` - Specifies if the client should disable 43 remote task execution to tasks running on this client. 44 45 - `meta` `(map[string]string: nil)` - Specifies a key-value map that annotates 46 with user-defined metadata. 47 48 - `network_interface` `(string: varied)` - Specifies the name of the interface 49 to force network fingerprinting on. When run in dev mode, this defaults to the 50 loopback interface. When not in dev mode, the interface attached to the 51 default route is used. The scheduler chooses from these fingerprinted IP 52 addresses when allocating ports for tasks. 53 54 If no non-local IP addresses are found, Nomad could fingerprint link-local IPv6 55 addresses depending on the client's 56 [`"fingerprint.network.disallow_link_local"`](#fingerprint-network-disallow_link_local) 57 configuration value. 58 59 - `cpu_total_compute` `(int: 0)` - Specifies an override for the total CPU 60 compute. This value should be set to `# Cores * Core MHz`. For example, a 61 quad-core running at 2 GHz would have a total compute of 8000 (4 \* 2000). Most 62 clients can determine their total CPU compute automatically, and thus in most 63 cases this should be left unset. 64 65 - `memory_total_mb` `(int:0)` - Specifies an override for the total memory. If set, 66 this value overrides any detected memory. 67 68 - `node_class` `(string: "")` - Specifies an arbitrary string used to logically 69 group client nodes by user-defined class. This can be used during job 70 placement as a filter. 71 72 - `options` <code>([Options](#options-parameters): nil)</code> - Specifies a 73 key-value mapping of internal configuration for clients, such as for driver 74 configuration. 75 76 - `reserved` <code>([Reserved](#reserved-parameters): nil)</code> - Specifies 77 that Nomad should reserve a portion of the node's resources from receiving 78 tasks. This can be used to target a certain capacity usage for the node. For 79 example, 20% of the node's CPU could be reserved to target a CPU utilization 80 of 80%. 81 82 - `servers` `(array<string>: [])` - Specifies an array of addresses to the Nomad 83 servers this client should join. This list is used to register the client with 84 the server nodes and advertise the available resources so that the agent can 85 receive work. This may be specified as an IP address or DNS, with or without 86 the port. If the port is omitted, the default port of `4647` is used. 87 88 - `server_join` <code>([server_join][server-join]: nil)</code> - Specifies 89 how the Nomad client will connect to Nomad servers. The `start_join` field 90 is not supported on the client. The retry_join fields may directly specify 91 the server address or use go-discover syntax for auto-discovery. See the 92 documentation for more detail. 93 94 - `state_dir` `(string: "[data_dir]/client")` - Specifies the directory to use 95 to store client state. By default, this is - the top-level 96 [data_dir](/docs/configuration#data_dir) suffixed with 97 "client", like `"/opt/nomad/client"`. This must be an absolute path. 98 99 - `gc_interval` `(string: "1m")` - Specifies the interval at which Nomad 100 attempts to garbage collect terminal allocation directories. 101 102 - `gc_disk_usage_threshold` `(float: 80)` - Specifies the disk usage percent which 103 Nomad tries to maintain by garbage collecting terminal allocations. 104 105 - `gc_inode_usage_threshold` `(float: 70)` - Specifies the inode usage percent 106 which Nomad tries to maintain by garbage collecting terminal allocations. 107 108 - `gc_max_allocs` `(int: 50)` - Specifies the maximum number of allocations 109 which a client will track before triggering a garbage collection of terminal 110 allocations. This will _not_ limit the number of allocations a node can run at 111 a time, however after `gc_max_allocs` every new allocation will cause terminal 112 allocations to be GC'd. 113 114 - `gc_parallel_destroys` `(int: 2)` - Specifies the maximum number of 115 parallel destroys allowed by the garbage collector. This value should be 116 relatively low to avoid high resource usage during garbage collections. 117 118 - `no_host_uuid` `(bool: true)` - By default a random node UUID will be 119 generated, but setting this to `false` will use the system's UUID. Before 120 Nomad 0.6 the default was to use the system UUID. 121 122 - `cni_path` `(string: "/opt/cni/bin")` - Sets the search path that is used for 123 CNI plugin discovery. Multiple paths can be searched using colon delimited 124 paths 125 126 - `cni_config_dir` `(string: "/opt/cni/config")` - Sets the directory where CNI 127 network configuration is located. The client will use this path when fingerprinting 128 CNI networks. Filenames should use the `.conflist` extension. 129 130 - `bridge_network name` `(string: "nomad")` - Sets the name of the bridge to be 131 created by nomad for allocations running with bridge networking mode on the 132 client. 133 134 - `bridge_network_subnet` `(string: "172.26.64.0/20")` - Specifies the subnet 135 which the client will use to allocate IP addresses from. 136 137 - `template` <code>([Template](#template-parameters): nil)</code> - Specifies 138 controls on the behavior of task 139 [`template`](/docs/job-specification/template) stanzas. 140 141 - `host_volume` <code>([host_volume](#host_volume-stanza): nil)</code> - Exposes 142 paths from the host as volumes that can be mounted into jobs. 143 144 - `host_network` <code>([host_network](#host_network-stanza): nil)</code> - Registers 145 additional host networks with the node that can be selected when port mapping. 146 147 ### `chroot_env` Parameters 148 149 Drivers based on [isolated fork/exec](/docs/drivers/exec) implement file 150 system isolation using chroot on Linux. The `chroot_env` map allows the chroot 151 environment to be configured using source paths on the host operating system. 152 The mapping format is: 153 154 ```text 155 source_path -> dest_path 156 ``` 157 158 The following example specifies a chroot which contains just enough to run the 159 `ls` utility: 160 161 ```hcl 162 client { 163 chroot_env { 164 "/bin/ls" = "/bin/ls" 165 "/etc/ld.so.cache" = "/etc/ld.so.cache" 166 "/etc/ld.so.conf" = "/etc/ld.so.conf" 167 "/etc/ld.so.conf.d" = "/etc/ld.so.conf.d" 168 "/etc/passwd" = "/etc/passwd" 169 "/lib" = "/lib" 170 "/lib64" = "/lib64" 171 } 172 } 173 ``` 174 175 When `chroot_env` is unspecified, the `exec` driver will use a default chroot 176 environment with the most commonly used parts of the operating system. Please 177 see the [Nomad `exec` driver documentation](/docs/drivers/exec#chroot) for 178 the full list. 179 180 ### `options` Parameters 181 182 ~> Note: In Nomad 0.9 client configuration options for drivers were deprecated. 183 See the [plugin stanza][plugin-stanza] documentation for more information. 184 185 The following is not an exhaustive list of options for only the Nomad 186 client. To find the options supported by each individual Nomad driver, please 187 see the [drivers documentation](/docs/drivers). 188 189 - `"driver.allowlist"` `(string: "")` - Specifies a comma-separated list of 190 allowlisted drivers . If specified, drivers not in the allowlist will be 191 disabled. If the allowlist is empty, all drivers are fingerprinted and enabled 192 where applicable. 193 194 ```hcl 195 client { 196 options = { 197 "driver.allowlist" = "docker,qemu" 198 } 199 } 200 ``` 201 202 - `"driver.denylist"` `(string: "")` - Specifies a comma-separated list of 203 denylisted drivers . If specified, drivers in the denylist will be 204 disabled. 205 206 ```hcl 207 client { 208 options = { 209 "driver.denylist" = "docker,qemu" 210 } 211 } 212 ``` 213 214 - `"env.denylist"` `(string: see below)` - Specifies a comma-separated list of 215 environment variable keys not to pass to these tasks. Nomad passes the host 216 environment variables to `exec`, `raw_exec` and `java` tasks. If specified, 217 the defaults are overridden. If a value is provided, **all** defaults are 218 overridden (they are not merged). 219 220 ```hcl 221 client { 222 options = { 223 "env.denylist" = "MY_CUSTOM_ENVVAR" 224 } 225 } 226 ``` 227 228 The default list is: 229 230 ```text 231 CONSUL_TOKEN 232 CONSUL_HTTP_TOKEN 233 VAULT_TOKEN 234 AWS_ACCESS_KEY_ID 235 AWS_SECRET_ACCESS_KEY 236 AWS_SESSION_TOKEN 237 GOOGLE_APPLICATION_CREDENTIALS 238 ``` 239 240 - `"user.denylist"` `(string: see below)` - Specifies a comma-separated 241 denylist of usernames for which a task is not allowed to run. This only 242 applies if the driver is included in `"user.checked_drivers"`. If a value is 243 provided, **all** defaults are overridden (they are not merged). 244 245 ```hcl 246 client { 247 options = { 248 "user.denylist" = "root,ubuntu" 249 } 250 } 251 ``` 252 253 The default list is: 254 255 ```text 256 root 257 Administrator 258 ``` 259 260 - `"user.checked_drivers"` `(string: see below)` - Specifies a comma-separated 261 list of drivers for which to enforce the `"user.denylist"`. For drivers using 262 containers, this enforcement is usually unnecessary. If a value is provided, 263 **all** defaults are overridden (they are not merged). 264 265 ```hcl 266 client { 267 options = { 268 "user.checked_drivers" = "exec,raw_exec" 269 } 270 } 271 ``` 272 273 The default list is: 274 275 ```text 276 exec 277 qemu 278 java 279 ``` 280 281 - `"fingerprint.allowlist"` `(string: "")` - Specifies a comma-separated list of 282 allowlisted fingerprinters. If specified, any fingerprinters not in the 283 allowlist will be disabled. If the allowlist is empty, all fingerprinters are 284 used. 285 286 ```hcl 287 client { 288 options = { 289 "fingerprint.allowlist" = "network" 290 } 291 } 292 ``` 293 294 - `"fingerprint.denylist"` `(string: "")` - Specifies a comma-separated list of 295 denylisted fingerprinters. If specified, any fingerprinters in the denylist 296 will be disabled. 297 298 ```hcl 299 client { 300 options = { 301 "fingerprint.denylist" = "network" 302 } 303 } 304 ``` 305 306 - `"fingerprint.network.disallow_link_local"` `(string: "false")` - Specifies 307 whether the network fingerprinter should ignore link-local addresses in the 308 case that no globally routable address is found. The fingerprinter will always 309 prefer globally routable addresses. 310 311 ```hcl 312 client { 313 options = { 314 "fingerprint.network.disallow_link_local" = "true" 315 } 316 } 317 ``` 318 319 ### `reserved` Parameters 320 321 - `cpu` `(int: 0)` - Specifies the amount of CPU to reserve, in MHz. 322 323 - `memory` `(int: 0)` - Specifies the amount of memory to reserve, in MB. 324 325 - `disk` `(int: 0)` - Specifies the amount of disk to reserve, in MB. 326 327 - `reserved_ports` `(string: "")` - Specifies a comma-separated list of ports to 328 reserve on all fingerprinted network devices. Ranges can be specified by using 329 a hyphen separated the two inclusive ends. 330 331 ### `template` Parameters 332 333 - `function_denylist` `([]string: ["plugin"])` - Specifies a list of template 334 rendering functions that should be disallowed in job specs. By default the 335 `plugin` function is disallowed as it allows running arbitrary commands on 336 the host as root (unless Nomad is configured to run as a non-root user). 337 338 - `disable_file_sandbox` `(bool: false)` - Allows templates access to arbitrary 339 files on the client host via the `file` function. By default templates can 340 access files only within the [task working directory]. 341 342 ### `host_volume` Stanza 343 344 The `host_volume` stanza is used to make volumes available to jobs. 345 346 The key of the stanza corresponds to the name of the volume for use in the 347 `source` parameter of a `"host"` type [`volume`](/docs/job-specification/volume) 348 and ACLs. 349 350 ```hcl 351 client { 352 host_volume "ca-certificates" { 353 path = "/etc/ssl/certs" 354 read_only = true 355 } 356 } 357 ``` 358 359 #### `host_volume` Parameters 360 361 - `path` `(string: "", required)` - Specifies the path on the host that should 362 be used as the source when this volume is mounted into a task. The path must 363 exist on client startup. 364 365 - `read_only` `(bool: false)` - Specifies whether the volume should only ever be 366 allowed to be mounted `read_only`, or if it should be writeable. 367 368 ### `host_network` Stanza 369 370 The `host_network` stanza is used to register additional host networks with 371 the node that can be used when port mapping. 372 373 The key of the stanza corresponds to the name of the network used in the 374 [`host_network`](/docs/job-specification/network#host-networks). 375 376 ```hcl 377 client { 378 host_network "public" { 379 cidr = "203.0.113.0/24" 380 reserved_ports = "22,80" 381 } 382 } 383 ``` 384 385 #### `host_network` Parameters 386 387 - `cidr` `(string: "")` - Specifies a cidr block of addresses to match against. 388 If an address is found on the node that is contained by this cidr block, the 389 host network will be registered with it. 390 391 - `interface` `(string: "")` - Filters searching of addresses to a specific interface. 392 393 - `reserved_ports` `(string: "")` - Specifies a comma-separated list of ports to 394 reserve on all fingerprinted network devices. Ranges can be specified by using 395 a hyphen separating the two inclusive ends. 396 397 ## `client` Examples 398 399 ### Common Setup 400 401 This example shows the most basic configuration for a Nomad client joined to a 402 cluster. 403 404 ```hcl 405 client { 406 enabled = true 407 server_join { 408 retry_join = [ "1.1.1.1", "2.2.2.2" ] 409 retry_max = 3 410 retry_interval = "15s" 411 } 412 } 413 ``` 414 415 ### Reserved Resources 416 417 This example shows a sample configuration for reserving resources to the client. 418 This is useful if you want to allocate only a portion of the client's resources 419 to jobs. 420 421 ```hcl 422 client { 423 enabled = true 424 425 reserved { 426 cpu = 500 427 memory = 512 428 disk = 1024 429 reserved_ports = "22,80,8500-8600" 430 } 431 } 432 ``` 433 434 ### Custom Metadata, Network Speed, and Node Class 435 436 This example shows a client configuration which customizes the metadata, network 437 speed, and node class. The scheduler can use this information while processing 438 [constraints][metadata_constraint]. The metadata is completely user configurable; 439 the values below are for illustrative purposes only. 440 441 ```hcl 442 client { 443 enabled = true 444 node_class = "prod" 445 446 meta { 447 owner = "ops" 448 cached_binaries = "redis,apache,nginx,jq,cypress,nodejs" 449 rack = "rack-12-1" 450 } 451 } 452 ``` 453 454 [plugin-options]: #plugin-options 455 [plugin-stanza]: /docs/configuration/plugin 456 [server-join]: /docs/configuration/server_join 'Server Join' 457 [metadata_constraint]: /docs/job-specification/constraint#user-specified-metadata 'Nomad User-Specified Metadata Constraint Example' 458 [task working directory]: /docs/runtime/environment#task-directories 'Task directories'