Changed to uppercase + numbers + underscores; updated docs

This commit is contained in:
Chris Bednarski 2015-09-23 15:19:31 -07:00
parent de2a62e0e3
commit f37dedc3bc
3 changed files with 23 additions and 27 deletions

View File

@ -344,7 +344,7 @@ func parseTasks(result *[]*structs.Task, obj *hclobj.Object) error {
return nil
}
var reDynamicPorts *regexp.Regexp = regexp.MustCompile("^[a-z0-9_]+$")
var reDynamicPorts *regexp.Regexp = regexp.MustCompile("^[A-Z0-9_]+$")
var errDynamicPorts = fmt.Errorf("DynamicPort label does not conform to naming requirements %s", reDynamicPorts.String())
func parseResources(result *structs.Resources, obj *hclobj.Object) error {

View File

@ -26,37 +26,33 @@ Nomad will pass CPU and memory to your job as `NOMAD_CPU_LIMIT` and
fit inside the resource allocation that nomad provides. For example, you can use
the memory limit to inform how large your in-process cache should be, or to
decide when to flush buffers to disk.
<!-- -->
Both CPU and memory are presented as integers. The unit for CPU limit is `1024 = 1Ghz`. The unit for memory is megabytes.
Both CPU and memory are presented as integers. The unit for CPU limit is
`1024 = 1Ghz`. The unit for memory `1 = 1 megabytes`.
Writing your applications to adjust to these values at runtime provides greater
scheduling flexibility since you can adjust the resource allocations in your
jobspec without needing to change your code. You can also schedule workloads that
use dynamic resource allocations so they can scale down/up as your cluster gets
more or less busy.
jobspec without needing to change your code. You can also schedule workloads
that accept dynamic resource allocations so they can scale down/up as your
cluster gets more or less busy.
### IPs and Named Ports
Each task will receive port allocations on a single IP address. The IP is made
available through `NOMAD_IP.`
If you requested reserved ports in your jobspec and your task is successfully scheduled, these ports are available for your use. Ports from `reserved_ports` in the job spec
are not exposed through the environment. If you requested dynamic ports in your
jobspec these are made known to your application via environment variables
`NOMAD_PORT_{LABEL}`. For example `dynamic_ports = ["http"]` becomes
`NOMAD_PORT_HTTP`.
If you requested reserved ports in your jobspec and your task is successfully
scheduled, these ports are available for your use. Ports from `reserved_ports`
in the job spec are not exposed through the environment. If you requested
dynamic ports in your jobspec these are made known to your application via
environment variables `NOMAD_PORT_{LABEL}`. For example
`dynamic_ports = ["HTTP"]` becomes `NOMAD_PORT_HTTP`.
Some drivers such as Docker and QEMU use port mapping. With port mapping the
application code can run on a fixed port and nomad will automatically map a
random allocated port in the driver. In this case, you should use numeric port
labels to indicate which ports are exposed in your container or VM. For example
with `dynamic_ports = ["5000"]` Docker will automatically map the allocated host
port to port 5000 in the container.
Even with automatic port mapping, numeric ports are also exported via
environment variables such as `NOMAD_PORT_5000` so you can use these with
drivers that do not support port mapping. You may also be able to use named
ports if you want to bind to a dynamic port inside a container or VM.
Some drivers such as Docker and QEMU use port mapping. If a driver supports port
mapping and you specify a numeric label, the label will be automatically used as
the private port number. For example, `dynamic_ports = ["5000"]` will have a
random port mapped to port 5000 inside the container or VM. These ports are also
exported as environment variables for consistency, e.g. `NOMAD_PORT_5000`.
Please see the relevant driver documentation for exact details.

View File

@ -185,11 +185,11 @@ The `resources` object supports the following keys:
The `network` object supports teh following keys:
* `dynamic_ports` - List of port labels which may contain letters, numbers and underscores.
Each label will be associated with a dynamic port when the task starts. Port allocation
will be passed to the task as an environment variable like `NOMAD_PORT_{{ .Label }}`
(upper-cased). Some Drivers may infer additional semantics from the label. See
[Docker](/docs/drivers/docker.html) for an example.
* `dynamic_ports` - List of port labels which may contain uppercase letters,
numbers and underscores (`^[A-Z0-9_]+$`). Each label will be assigned a
dynamic port when the task starts. Ports are passed to the task environment as
`NOMAD_PORT_{LABEL}`. Drivers may infer additional semantics from the label.
See the relevant driver docs for details.
* `mbits` - The number of MBits in bandwidth required.