From ff27b6fcaf18f7486ab1da1fc1abbb1c6629c42e Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Mon, 3 Oct 2016 16:59:56 -0400 Subject: [PATCH] Update docs on interpreted Uses "property" instead of overloading "attribute" --- .../source/docs/jobspec/interpreted.html.md | 159 ++++++++++-------- 1 file changed, 90 insertions(+), 69 deletions(-) diff --git a/website/source/docs/jobspec/interpreted.html.md b/website/source/docs/jobspec/interpreted.html.md index 81d79f7d6..1a06b2603 100644 --- a/website/source/docs/jobspec/interpreted.html.md +++ b/website/source/docs/jobspec/interpreted.html.md @@ -17,7 +17,7 @@ The syntax for interpreting variables is `${variable}`. An example and a comprehensive list of interpretable fields can be seen below: ```hcl -task "demo" { +task "docs" { driver = "docker" # Drivers support interpreting node attributes and runtime environment @@ -61,100 +61,126 @@ task "demo" { ## Node Variables Below is a full listing of node attributes that are interpretable. These -attributes are Interpreted by __both__ constraints and within the task and +attributes are interpreted by __both__ constraints and within the task and driver. - + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + +
Variable DescriptionExampleExample Value
${node.unique.id}The 36 character unique client node identifier9afa5da1-8f39-25a2-48dc-ba31fd7c0023${node.unique.id}36 character unique client identifier9afa5da1-8f39-25a2-48dc-ba31fd7c0023
${node.datacenter}The client node's datacenterdc1${node.datacenter}Client's datacenterdc1
${node.unique.name}The client node's namenomad-client-10-1-2-4${node.unique.name}Client's namenomad-client-10-1-2-4
${node.class}The client node's classlinux-64bit${node.class}Client's classlinux-64bit
${attr."key"}The attribute given by `key` on the client node.platform.aws.instance-type:r3.large${attr.<property>}Property given by property on the client${attr.arch} => amd64
${meta."key"}The metadata value given by `key` on the client node.${meta.<key>}Metadata value given by key on the client${meta.foo} => bar
-Below is a table documenting common node attributes: +Below is a table documenting common node properties: - + - - + + - - + + - + - - + + - + - - + + - - + + - - + + - - + + - - + + - +
AttributeProperty Description
archCPU architecture of the client. Examples: `amd64`, `386`archCPU architecture of the client (e.g. amd64, 386)
consul.datacenterThe Consul datacenter of the client node if Consul foundconsul.datacenterThe Consul datacenter of the client (if Consul is found)
cpu.numcorescpu.numcores Number of CPU cores on the client
driver."key"See the [task drivers](/docs/drivers/index.html) for attribute documentationdriver.<property>See the [task drivers](/docs/drivers/index.html) for property documentation
unique.hostnameunique.hostname Hostname of the client
kernel.nameKernel of the client. Examples: `linux`, `darwin`kernel.nameKernel of the client (e.g. linux, darwin)
kernel.versionVersion of the client kernel. Examples: `3.19.0-25-generic`, `15.0.0`kernel.versionVersion of the client kernel (e.g. 3.19.0-25-generic, 15.0.0)
platform.aws.ami-idOn EC2, the AMI ID of the client nodeplatform.aws.ami-idAMI ID of the client (if on AWS EC2)
platform.aws.instance-typeOn EC2, the instance type of the client nodeplatform.aws.instance-typeInstance type of the client (if on AWS EC2)
os.nameOperating system of the client. Examples: `ubuntu`, `windows`, `darwin`os.nameOperating system of the client (e.g. ubuntu, windows, darwin)
os.versionos.version Version of the client OS
+Here are some examples of using node attributes and properties in a job file: + +```hcl +job "docs" { + # This will constrain this job to only run on 64-bit clients. + constraint { + attribute = "${attr.arch}" + value = "amd64" + } + + # This will restrict the job to only run on clients with 4 or more cores. + # Note: you may also declare a resource requirement for CPU for a task. + constraint { + attribute = "${cpu.numcores}" + operator = ">=" + value = "4" + } + + # Only run this job on a memory-optimized AWS EC2 instance. + constraint { + attribute = "${attr.platform.aws.instance-type}" + value = "m4.xlarge" + } +} +``` + ## Environment Variables The following are runtime environment variables that describe the environment @@ -167,68 +193,63 @@ a particular node and as such can not be used in constraints. Description - ${NOMAD_ALLOC_DIR} - The path to the shared `alloc/` directory. See - [here](/docs/jobspec/environment.html#task_dir) for more - information. + ${NOMAD_ALLOC_DIR} + The path to the shared alloc/ directory. See [here](/docs/jobspec/environment.html#task_dir) for more information. - ${NOMAD_TASK_DIR} - The path to the task `local/` directory. See - [here](/docs/jobspec/environment.html#task_dir) for more - information. + ${NOMAD_TASK_DIR} + The path to the task local/ directory. See [here](/docs/jobspec/environment.html#task_dir) for more information. - ${NOMAD_MEMORY_LIMIT} + ${NOMAD_MEMORY_LIMIT} The memory limit in MBytes for the task - ${NOMAD_CPU_LIMIT} + ${NOMAD_CPU_LIMIT} The CPU limit in MHz for the task - ${NOMAD_ALLOC_ID} + ${NOMAD_ALLOC_ID} The allocation ID of the task - ${NOMAD_ALLOC_NAME} + ${NOMAD_ALLOC_NAME} The allocation name of the task - ${NOMAD_ALLOC_INDEX} + ${NOMAD_ALLOC_INDEX} The allocation index; useful to distinguish instances of task groups - ${NOMAD_TASK_NAME} + ${NOMAD_TASK_NAME} The task's name - ${NOMAD_IP_"label"} - The IP for the given port `label`. See + ${NOMAD_IP_<label>} + The IP for the given port label. See [here](/docs/jobspec/networking.html) for more information. - ${NOMAD_PORT_"label"} - The port for the port `label`. See [here](/docs/jobspec/networking.html) - for more information. + ${NOMAD_PORT_<label>} + The port for the port label. See [here](/docs/jobspec/networking.html) for more information. - ${NOMAD_ADDR_"label"} - The `ip:port` pair for the given port `label`. See + ${NOMAD_ADDR_<label>} + The ip:port pair for the given port label. See [here](/docs/jobspec/networking.html) for more information. - ${NOMAD_HOST_PORT_"label"} + ${NOMAD_HOST_PORT_<label>} The port on the host if port forwarding is being used for the port - `label`. See [here](/docs/jobspec/networking.html#mapped_ports) for more + label. See [here](/docs/jobspec/networking.html#mapped_ports) for more information. - ${NOMAD_META_"key"} - The metadata value given by `key` on the task's metadata + ${NOMAD_META_<key>} + The metadata value given by key on the task's metadata - ${"env_key"} - Interpret an environment variable with key `env_key` set on the task. + ${"env_key"} + Interpret an environment variable with key env_key set on the task.