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