Merge branch 'master' into dev/net-fingerprint

This commit is contained in:
Antoine POPINEAU
2015-10-02 09:38:35 +02:00
20 changed files with 346 additions and 113 deletions

1
.gitignore vendored
View File

@@ -26,6 +26,7 @@ _testmain.go
*.prof
bin/
pkg/
.vagrant/
website/build/
website/npm-debug.log

View File

@@ -7,33 +7,33 @@ EXTERNAL_TOOLS=\
golang.org/x/tools/cmd/cover \
golang.org/x/tools/cmd/vet
all: test
all: deps format
@mkdir -p bin/
@bash --norc -i ./scripts/build.sh
dev: deps format
@NOMAD_DEV=1 sh -c "'$(CURDIR)/scripts/build.sh'"
bin:
@sh -c "'$(CURDIR)/scripts/build.sh'"
release: updatedeps
@$(MAKE) bin
cov:
gocov test ./... | gocov-html > /tmp/coverage.html
open /tmp/coverage.html
deps:
@echo "--> Installing build dependencies"
@bash --norc scripts/deps.sh -d -v
@DEP_ARGS="-d -v" sh -c "'$(CURDIR)/scripts/deps.sh'"
updatedeps: deps
@echo "--> Updating build dependencies"
@bash --norc scripts/deps.sh -d -f -u
@DEP_ARGS="-d -f -u" sh -c "'$(CURDIR)/scripts/deps.sh'"
test: deps
@./scripts/test.sh
@sh -c "'$(CURDIR)/scripts/test.sh'"
@$(MAKE) vet
integ:
go list ./... | INTEG_TESTS=yes xargs -n1 go test
cover: deps
go list ./... | xargs -n1 go test --cover

View File

@@ -96,12 +96,22 @@ $ make test
...
```
To compile a development version of Nomad, run `make`. This will put the
To compile a development version of Nomad, run `make dev`. This will put the
Nomad binary in the `bin` and `$GOPATH/bin` folders:
```sh
$ make
$ make dev
...
$ bin/nomad
...
```
To cross-compile Nomad, run `make bin`. This will compile Nomad for multiple
platforms and place the resulting binaries into the `./pkg` directory:
```sh
$ make bin
...
$ ls ./pkg
...
```

4
Vagrantfile vendored
View File

@@ -19,8 +19,8 @@ ARCH=`uname -m | sed 's|i686|386|' | sed 's|x86_64|amd64|'`
# Install Go
cd /tmp
wget -q https://storage.googleapis.com/golang/go1.4.2.linux-${ARCH}.tar.gz
tar -xf go1.4.2.linux-${ARCH}.tar.gz
wget -q https://storage.googleapis.com/golang/go1.5.1.linux-${ARCH}.tar.gz
tar -xf go1.5.1.linux-${ARCH}.tar.gz
sudo mv go $SRCROOT
sudo chmod 775 $SRCROOT
sudo chown vagrant:vagrant $SRCROOT

View File

@@ -118,6 +118,23 @@ func createContainer(ctx *ExecContext, task *structs.Task, logger *log.Logger) d
logger.Printf("[DEBUG] driver.docker: using %d bytes memory for %s", hostConfig.Memory, task.Config["image"])
logger.Printf("[DEBUG] driver.docker: using %d cpu shares for %s", hostConfig.CPUShares, task.Config["image"])
mode, ok := task.Config["network_mode"]
if !ok || mode == "" {
// docker default
logger.Printf("[WARN] driver.docker: no mode specified for networking, defaulting to bridge")
mode = "bridge"
}
// Ignore the container mode for now
switch mode {
case "default", "bridge", "none", "host":
logger.Printf("[DEBUG] driver.docker: using %s as network mode", mode)
default:
logger.Printf("[WARN] invalid setting for network mode %s, defaulting to bridge mode on docker0", mode)
mode = "bridge"
}
hostConfig.NetworkMode = mode
// Setup port mapping (equivalent to -p on docker CLI). Ports must already be
// exposed in the container.
if len(task.Resources.Networks) == 0 {

View File

@@ -287,3 +287,29 @@ func TestDocker_StartNVersions(t *testing.T) {
t.Log("==> Test complete!")
}
func TestDockerHostNet(t *testing.T) {
task := &structs.Task{
Config: map[string]string{
"image": "redis",
"network_mode": "host",
},
Resources: &structs.Resources{
MemoryMB: 256,
CPU: 512,
},
}
driverCtx := testDriverContext(task.Name)
ctx := testDriverExecContext(task, driverCtx)
defer ctx.AllocDir.Destroy()
d := NewDockerDriver(driverCtx)
handle, err := d.Start(ctx, task)
if err != nil {
t.Fatalf("err: %v", err)
}
if handle == nil {
t.Fatalf("missing handle")
}
defer handle.Kill()
}

View File

@@ -95,7 +95,15 @@ func (f *StorageFingerprint) Fingerprint(cfg *config.Config, node *structs.Node)
}
// Use -k to standardize the output values between darwin and linux
mountOutput, err := exec.Command("df", "-k", path).Output()
var dfArgs string
if runtime.GOOS == "linux" {
// df on linux needs the -P option to prevent linebreaks on long filesystem paths
dfArgs = "-kP"
} else {
dfArgs = "-k"
}
mountOutput, err := exec.Command("df", dfArgs, path).Output()
if err != nil {
return false, fmt.Errorf("Failed to determine mount point for %s", path)
}

View File

@@ -50,6 +50,8 @@ type Command struct {
func (c *Command) readConfig() *Config {
var dev bool
var configPath []string
var servers string
var meta []string
// Make a new, empty config.
cmdConfig := &Config{
@@ -70,6 +72,14 @@ func (c *Command) readConfig() *Config {
// Server-only options
flags.IntVar(&cmdConfig.Server.BootstrapExpect, "bootstrap-expect", 0, "")
// Client-only options
flags.StringVar(&cmdConfig.Client.StateDir, "state-dir", "", "")
flags.StringVar(&cmdConfig.Client.AllocDir, "alloc-dir", "", "")
flags.StringVar(&cmdConfig.Client.NodeID, "node-id", "", "")
flags.StringVar(&cmdConfig.Client.NodeClass, "node-class", "", "")
flags.StringVar(&servers, "servers", "", "")
flags.Var((*sliceflag.StringFlag)(&meta), "meta", "")
// General options
flags.Var((*sliceflag.StringFlag)(&configPath), "config", "config")
flags.StringVar(&cmdConfig.BindAddr, "bind", "", "")
@@ -88,6 +98,26 @@ func (c *Command) readConfig() *Config {
return nil
}
// Split the servers.
if servers != "" {
cmdConfig.Client.Servers = strings.Split(servers, ",")
}
// Parse the meta flags.
metaLength := len(meta)
if metaLength != 0 {
cmdConfig.Client.Meta = make(map[string]string, metaLength)
for _, kv := range meta {
parts := strings.SplitN(kv, "=", 2)
if len(parts) != 2 {
c.Ui.Error(fmt.Sprintf("Error parsing Client.Meta value: %v", kv))
return nil
}
cmdConfig.Client.Meta[parts[0]] = parts[1]
}
}
// Load the configuration
var config *Config
if dev {
@@ -134,12 +164,27 @@ func (c *Command) readConfig() *Config {
return config
}
// Check that we have a data-dir
if config.DataDir == "" {
// Check that the server is running in at least one mode.
if !(config.Server.Enabled || config.Client.Enabled) {
c.Ui.Error("Must specify either server, client or dev mode for the agent.")
return nil
}
// Ensure that we have the directories we neet to run.
if config.Server.Enabled && config.DataDir == "" {
c.Ui.Error("Must specify data directory")
return nil
}
// The config is valid if the top-level data-dir is set or if both
// alloc-dir and state-dir are set.
if config.Client.Enabled && config.DataDir == "" {
if config.Client.AllocDir == "" || config.Client.StateDir == "" {
c.Ui.Error("Must specify both the state and alloc dir if data-dir is omitted.")
return nil
}
}
// Check the bootstrap flags
if config.Server.BootstrapExpect > 0 && !config.Server.Enabled {
c.Ui.Error("Bootstrap requires server mode to be enabled")
@@ -588,9 +633,35 @@ Server Options:
Client Options:
-client
Enable client mode for the agent. Client mode enables a given node
to be evaluated for allocations. If client mode is not enabled,
no work will be scheduled to the agent.
Enable client mode for the agent. Client mode enables a given node to be
evaluated for allocations. If client mode is not enabled, no work will be
scheduled to the agent.
-state-dir
The directory used to store state and other persistent data. If not
specified a subdirectory under the "-data-dir" will be used.
-alloc-dir
The directory used to store allocation data such as downloaded artificats as
well as data produced by tasks. If not specified, a subdirectory under the
"-data-dir" will be used.
-servers
A list of known server addresses to connect to given as "host:port" and
delimited by commas.
-node-id
A unique identifier for the node to use. If not provided, a UUID is
generated.
-node-class
Mark this node as a member of a node-class. This can be used to label
similiar node types.
-meta
User specified metadata to associated with the node. Each instance of -meta
parses a single KEY=VALUE pair. Repeat the meta flag for each key/value pair
to be added.
Atlas Options:

View File

@@ -27,16 +27,24 @@ func TestCommand_Args(t *testing.T) {
tcases := []tcase{
{
[]string{},
"Must specify data directory",
"Must specify either server, client or dev mode for the agent.",
},
{
[]string{"-data-dir=" + tmpDir, "-bootstrap-expect=1"},
[]string{"-client", "-data-dir=" + tmpDir, "-bootstrap-expect=1"},
"Bootstrap requires server mode to be enabled",
},
{
[]string{"-data-dir=" + tmpDir, "-server", "-bootstrap-expect=1"},
"WARNING: Bootstrap mode enabled!",
},
{
[]string{"-server"},
"Must specify data directory",
},
{
[]string{"-client", "-alloc-dir="},
"Must specify both the state and alloc dir if data-dir is omitted.",
},
}
for _, tc := range tcases {
// Make a new command. We pre-emptively close the shutdownCh

View File

@@ -25,7 +25,6 @@ Usage: nomad init
Creates an example job file that can be used as a starting
point to customize further.
`
return strings.TrimSpace(helpText)
}
@@ -35,15 +34,22 @@ func (c *InitCommand) Synopsis() string {
}
func (c *InitCommand) Run(args []string) int {
// Check for misuse
if len(args) != 0 {
c.Ui.Error(c.Help())
return 1
}
// Check if the file already exists
_, err := os.Stat(DefaultInitName)
if err == nil || !os.IsNotExist(err) {
c.Ui.Error(fmt.Sprintf("Job '%s' already exists", DefaultInitName))
return 1
} else if !os.IsNotExist(err) {
if err != nil && !os.IsNotExist(err) {
c.Ui.Error(fmt.Sprintf("Failed to stat '%s': %v", DefaultInitName, err))
return 1
}
if !os.IsNotExist(err) {
c.Ui.Error(fmt.Sprintf("Job '%s' already exists", DefaultInitName))
return 1
}
// Write out the example
err = ioutil.WriteFile(DefaultInitName, []byte(defaultJob), 0660)
@@ -57,7 +63,7 @@ func (c *InitCommand) Run(args []string) int {
return 0
}
const defaultJob = `
var defaultJob = strings.TrimSpace(`
# There can only be a single job definition per file.
# Create a job with ID and Name 'example'
job "example" {
@@ -122,4 +128,4 @@ job "example" {
}
}
}
`
`)

65
command/init_test.go Normal file
View File

@@ -0,0 +1,65 @@
package command
import (
"io/ioutil"
"os"
"strings"
"testing"
"github.com/mitchellh/cli"
)
func TestInitCommand_Implements(t *testing.T) {
var _ cli.Command = &InitCommand{}
}
func TestInitCommand_Run(t *testing.T) {
ui := new(cli.MockUi)
cmd := &InitCommand{Meta: Meta{Ui: ui}}
// Fails on misuse
if code := cmd.Run([]string{"some", "bad", "args"}); code != 1 {
t.Fatalf("expect exit code 1, got: %d", code)
}
if out := ui.ErrorWriter.String(); !strings.Contains(out, cmd.Help()) {
t.Fatalf("expect help output, got: %s", out)
}
ui.ErrorWriter.Reset()
// Ensure we change the cwd back
origDir, err := os.Getwd()
if err != nil {
t.Fatalf("err: %s", err)
}
defer os.Chdir(origDir)
// Create a temp dir and change into it
dir, err := ioutil.TempDir("", "nomad")
if err != nil {
t.Fatalf("err: %s", err)
}
defer os.RemoveAll(dir)
if err := os.Chdir(dir); err != nil {
t.Fatalf("err: %s", err)
}
// Works if the file doesn't exist
if code := cmd.Run([]string{}); code != 0 {
t.Fatalf("expect exit code 0, got: %d", code)
}
content, err := ioutil.ReadFile(DefaultInitName)
if err != nil {
t.Fatalf("err: %s", err)
}
if string(content) != defaultJob {
t.Fatalf("unexpected file content\n\n%s", string(content))
}
// Fails if the file exists
if code := cmd.Run([]string{}); code != 1 {
t.Fatalf("expect exit code 1, got: %d", code)
}
if out := ui.ErrorWriter.String(); !strings.Contains(out, "exists") {
t.Fatalf("expect file exists error, got: %s", out)
}
}

View File

@@ -32,11 +32,6 @@ func NomadExecutable() (string, error) {
}
// Check the CWD.
bin = filepath.Join(os.Getenv("GOPATH"), "bin", nomadExe)
if _, err := os.Stat(bin); err == nil {
return bin, nil
}
pwd, err := os.Getwd()
if err != nil {
return "", fmt.Errorf("Could not find Nomad executable (%v): %v", err)
@@ -47,5 +42,11 @@ func NomadExecutable() (string, error) {
return bin, nil
}
// Check CWD/bin
bin = filepath.Join(pwd, "bin", nomadExe)
if _, err := os.Stat(bin); err == nil {
return bin, nil
}
return "", fmt.Errorf("Could not find Nomad executable (%v)", nomadExe)
}

View File

@@ -65,7 +65,7 @@ for F in $(find ${DEV_PLATFORM} -mindepth 1 -maxdepth 1 -type f); do
cp ${F} ${MAIN_GOPATH}/bin/
done
if [[ "${NOMAD_DEV}" ]]; then
if [[ "x${NOMAD_DEV}" == "x" ]]; then
# Zip and copy to the dist dir
echo "==> Packaging..."
for PLATFORM in $(find ./pkg -mindepth 1 -maxdepth 1 -type d); do

View File

@@ -1,9 +1,9 @@
#!/bin/bash
# First get the OS-specific packages
GOOS=windows go get $@ github.com/StackExchange/wmi
GOOS=windows go get $@ github.com/shirou/w32
GOOS=windows go get $DEP_ARGS github.com/StackExchange/wmi
GOOS=windows go get $DEP_ARGS github.com/shirou/w32
# Get the rest of the deps
DEPS=$(go list -f '{{range .TestImports}}{{.}} {{end}}' ./...)
go get $@ ./... $DEPS
go get $DEP_ARGS ./... $DEPS

2
website/Vagrantfile vendored
View File

@@ -37,5 +37,5 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.network "private_network", ip: "33.33.30.10"
config.vm.network "forwarded_port", guest: 4567, host: 8080
config.vm.provision "shell", inline: $script, privileged: false
config.vm.synced_folder ".", "/vagrant", type: "rsync"
config.vm.synced_folder ".", "/vagrant"
end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

View File

@@ -354,13 +354,13 @@
.docker-outline-logo{
display: inline-block;
width: 125px;
height: 80px;
width: 80px;
height: 67px;
position: relative;
top: 12px;
margin-left: 10px;
background: image-url('../images/icon-docker-outline.png') 0 0 no-repeat;
@include img-retina("../images/icon-docker-outline.png", "../images/icon-docker-outline@2x.png", 125px, 80px);
margin-left: 8px;
background: image-url('../images/partner-docker.png') 0 0 no-repeat;
@include img-retina("../images/partner-docker.png", "../images/partner-docker@2x.png", 80px, 67px);
}
a{

View File

@@ -25,7 +25,7 @@ appended together. Any exceptions to these rules are documented alongside the
configuration options below.
A subset of the configuration options can also be specified using the
command-line interface. See the [CLI Options](#) section for further details.
command-line interface. See the [CLI Options](#cli) section for further details.
Nomad's configuration is broken down into logical groupings. Because of the high
number of configuration options available, this page is also broken into
@@ -36,17 +36,17 @@ sections for easier reading.
The following configuration options are available to both client and server
nodes, unless otherwise specified:
* `region`: Specifies the region the Nomad agent is a member of. A region
typically maps to a geographic region, for example `us`, with potentially
multiple zones, which map to [datacenters](#datacenter) such as `us-west`
and `us-east`. Defaults to `global`.
* <a id="region">`region`</a>: Specifies the region the Nomad agent is a
member of. A region typically maps to a geographic region, for example `us`,
with potentially multiple zones, which map to [datacenters](#datacenter) such
as `us-west` and `us-east`. Defaults to `global`.
* `datacenter`: Datacenter of the local agent. All members of a datacenter
should all share a local LAN connection. Defaults to `dc1`.
* `name`: The name of the local node. This value is used to identify individual
nodes in a given datacenter and must be unique per-datacenter. By default this
is set to the local host's name.
* <a id="name">`name`</a>: The name of the local node. This value is used to
identify individual nodes in a given datacenter and must be unique
per-datacenter. By default this is set to the local host's name.
* `data_dir`: A local directory used to store agent state. Client nodes use this
directory by default to store temporary allocation data as well as cluster
@@ -58,13 +58,13 @@ nodes, unless otherwise specified:
log levels include `WARN`, `INFO`, or `DEBUG` in increasing order of
verbosity. Defaults to `INFO`.
* `bind_addr`: Used to indicate which address the Nomad agent should bind to for
network services, including the HTTP interface as well as the internal gossip
protocol and RPC mechanism. This should be specified in IP format, and can be
used to easily bind all network services to the same address. It is also
possible to bind the individual services to different addresses using the
[addresses](#addresses) configuration option. Defaults to the local loopback
address `127.0.0.1`.
* <a id="bind_addr">`bind_addr`</a>: Used to indicate which address the Nomad
agent should bind to for network services, including the HTTP interface as
well as the internal gossip protocol and RPC mechanism. This should be
specified in IP format, and can be used to easily bind all network services to
the same address. It is also possible to bind the individual services to
different addresses using the [addresses](#addresses) configuration option.
Defaults to the local loopback address `127.0.0.1`.
* `enable_debug`: Enables the debugging HTTP endpoints. These endpoints can be
used with profiling tools to dump diagnostic information about Nomad's
@@ -84,10 +84,10 @@ nodes, unless otherwise specified:
TCP and UDP should be routable between the server nodes on this port.
Defaults to `4648`. Only used on server nodes.
* `addresses`: Controls the bind address for individual network services. Any
values configured in this block take precedence over the default
[bind_addr](#bind_addr). The value is a map of IP addresses and supports the
following keys:
* <a id="addresses">`addresses`</a>: Controls the bind address for individual
network services. Any values configured in this block take precedence over the
default [bind_addr](#bind_addr). The value is a map of IP addresses and
supports the following keys:
<br>
* `http`: The address the HTTP server is bound to. This is the most common
bind address to change. Applies to both clients and servers.
@@ -99,17 +99,19 @@ nodes, unless otherwise specified:
server nodes from the same datacenter if possible. Used only on server
nodes.
* `advertise`: Controls the advertise address for individual network services. Any
values configured in this block take precedence over the default
[bind_addr](#bind_addr). The value is a map of IP addresses and supports the
* `advertise`: Controls the advertise address for individual network services.
This can be used to advertise a different address to the peers of a server
node to support more complex network configurations such as NAT. This
configuration is optional, and defaults to the bind address of the specific
network service if it is not provided. This configuration is only appicable
on server nodes. The value is a map of IP addresses and supports the
following keys:
<br>
* `rpc`: The address to advertise for the RPC interface. Should be exposed
only to other cluster members if possible. Used only on server nodes, but
must be accessible from all agents.
* `serf`: The address used advertise for the gossip layer. Both a TCP and UDP
listener will be exposed on this address. Must be accessible from all
server nodes. Used only on server nodes.
* `rpc`: The address to advertise for the RPC interface. This address should
be reachable by all of the agents in the cluster.
* `serf`: The address advertised for the gossip layer. This address must be
reachable from all server nodes. It is not required that clients can reach
this address.
* `telemetry`: Used to control how the Nomad agent exposes telemetry data to
external metrics collection servers. This is a key/value mapping and supports
@@ -152,11 +154,11 @@ configured on client nodes.
* `enabled`: A boolean indicating if server mode should be enabled for the
local agent. All other server options depend on this value being set.
Defaults to `false`.
* `bootstrap_expect`: This is an integer representing the number of server
nodes to wait for before bootstrapping. It is most common to use the
odd-numbered integers `3` or `5` for this value, depending on the cluster
size. A value of `1` does not provide any fault tolerance and is not
recommended for production use cases.
* <a id="bootstrap_expect">`bootstrap_expect`</a>: This is an integer
representing the number of server nodes to wait for before bootstrapping. It
is most common to use the odd-numbered integers `3` or `5` for this value,
depending on the cluster size. A value of `1` does not provide any fault
tolerance and is not recommended for production use cases.
* `data_dir`: This is the data directory used for server-specific data,
including the replicated log. By default, this directory lives inside of the
[data_dir](#data_dir) in the "server" sub-path.
@@ -183,26 +185,28 @@ configured on server nodes.
<br>
* `enabled`: A boolean indicating if client mode is enabled. All other client
configuration options depend on this value. Defaults to `false`.
* `state_dir`: This is the state dir used to store client state. By default,
it lives inside of the [data_dir](#data_dir), in the "client" sub-path.
* `alloc_dir`: A directory used to store allocation data. Depending on the
workload, the size of this directory can grow arbitrarily large as it is
used to store downloaded artifacts for drivers (QEMU images, JAR files,
etc.). It is therefore important to ensure this directory is placed some
place on the filesystem with adequate storage capacity. By default, this
directory lives under the [state_dir](#state_dir) at the "alloc" sub-path.
* `servers`: An array of server addresses. This list is used to register the
client with the server nodes and advertise the available resources so that
the agent can receive work.
* `node_id`: This is the value used to uniquely identify the local agent's
node registration with the servers. This can be any arbitrary string but
must be unique to the cluster. By default, if not specified, a randomly-
generate UUID will be used.
* `node_class`: A string used to logically group client nodes by class. This
can be used during job placement as a filter. This option is not required
and has no default.
* `meta`: This is a key/value mapping of metadata pairs. This is a free-form
map and can contain any string values.
* <a id="state_dir">`state_dir`</a>: This is the state dir used to store
client state. By default, it lives inside of the [data_dir](#data_dir), in
the "client" sub-path.
* <a id="alloc_dir">`alloc_dir`</a>: A directory used to store allocation data.
Depending on the workload, the size of this directory can grow arbitrarily
large as it is used to store downloaded artifacts for drivers (QEMU images,
JAR files, etc.). It is therefore important to ensure this directory is
placed some place on the filesystem with adequate storage capacity. By
default, this directory lives under the [data_dir](#data_dir) at the
"alloc" sub-path.
* <a id="servers">`servers`</a>: An array of server addresses. This list is
used to register the client with the server nodes and advertise the
available resources so that the agent can receive work.
* <a id="node_id">`node_id`</a>: This is the value used to uniquely identify
the local agent's node registration with the servers. This can be any
arbitrary string but must be unique to the cluster. By default, if not
specified, a randomly- generate UUID will be used.
* <a id="node_class">`node_class`</a>: A string used to logically group client
nodes by class. This can be used during job placement as a filter. This
option is not required and has no default.
* <a id="meta">`meta`</a>: This is a key/value mapping of metadata pairs. This
is a free-form map and can contain any string values.
* `network_interface`: This is a string to force network fingerprinting to use
a specific network interface
@@ -215,38 +219,49 @@ integration and are entirely optional.
configuration options. The value is a key/value map which supports the
following keys:
<br>
* `infrastructure`: The Atlas infrastructure name to connect this agent to.
This value should be of the form `<org>/<infrastructure>`, and requires a
valid [token](#token) authorized on the infrastructure.
* `token`: The Atlas token to use for authentication. This token should have
access to the provided [infrastructure](#infrastructure).
* `join`: A boolean indicating if the auto-join feature of Atlas should be
enabled. Defaults to `false`.
* <a id="infrastructure">`infrastructure`</a>: The Atlas infrastructure name to
connect this agent to. This value should be of the form
`<org>/<infrastructure>`, and requires a valid [token](#token) authorized on
the infrastructure.
* <a id="token">`token`</a>: The Atlas token to use for authentication. This
token should have access to the provided [infrastructure](#infrastructure).
* <a id="join">`join`</a>: A boolean indicating if the auto-join feature of
Atlas should be enabled. Defaults to `false`.
* `endpoint`: The address of the Atlas instance to connect to. Defaults to the
public Atlas endpoint and is only used if both
[infrastructure](#infrastructure) and [token](#token) are provided.
## Command-line Options
## Command-line Options <a id="cli"></a>
A subset of the available Nomad agent configuration can optionally be passed in
via CLI arguments. The `agent` command accepts the following arguments:
* `alloc-dir=<path>`: Equivalent to the Client [alloc_dir](#alloc_dir) config
option.
* `-atlas=<infrastructure>`: Equivalent to the Atlas
[infrastructure](#infrastructure) config option.
* `-atlas-join`: Equivalent to the Atlas [join](#join) config option.
* `-atlas-token=<token>`: Equivalent to the Atlas [token](#token) config option.
* `-bind=<address>`: Equivalent to the [bind_addr](#bind_addr) config option.
* `-bootstrap-expect=<num>`: Equivalent to the
[bootstrap_expect](#bootstrap_expect) config option.
* `-client`: Enable client mode on the local agent.
* `-config=<path>`: Specifies the path to a configuration file or a directory of
configuration files to load. Can be specified multiple times.
* `-data-dir=<path>`: Equivalent to the [data_dir](#data_dir) config option.
* `-dc=<datacenter>`: Equivalent to the [datacenter](#datacenter) config option.
* `-log-level=<level>`: Equivalent to the [log_level](#log_level) config option.
* `-node=<name>`: Equivalent to the [node](#node) config option.
* `-region=<region>`: Equivalent to the [region](#region) config option.
* `-client`: Enable client mode on the local agent
* `-server`: Enable server mode on the local agent
* `-dev`: Start the agent in development mode. This enables a pre-configured
dual-role agent (client + server) which is useful for developing or testing
Nomad. No other configuration is required to start the agent in this mode.
* `-atlas=<infrastructure>`: Equivalent to the Atlas
[infrastructure](#infrastructure) config option.
* `-atlas-token=<token>`: Equivalent to the Atlas [token](#token) config option.
* `-atlas-join`: Equivalent to the Atlas [join](#join) config option.
* `-log-level=<level>`: Equivalent to the [log_level](#log_level) config option.
* `-meta=<key=value>`: Equivalent to the Client [meta](#meta) config option.
* `-node=<name>`: Equivalent to the [name](#name) config option.
* `-node-class=<class>`: Equivalent to the Client [node_class](#node_class)
config option.
* `-node-id=<uuid>`: Equivalent to the Client [node_id](#node_id) config option.
* `-region=<region>`: Equivalent to the [region](#region) config option.
* `-server`: Enable server mode on the local agent.
* `-servers=<host:port>`: Equivalent to the Client [servers](#servers) config
option.
* `-state-dir=<path>`: Equivalent to the Client [state_dir](#state_dir) config
option.

View File

@@ -23,6 +23,11 @@ The `docker` driver supports the following configuration in the job specificatio
* `command` - (Optional) The command to run when starting the container.
* `network_mode` - (Optional) The network mode to be used for the container.
Valid options are `net`, `bridge`, `host` or `none`. If nothing is
specified, the container will start in `bridge` mode. The `container`
network mode is not supported right now.
### Port Mapping
Nomad uses port binding to expose services running in containers using the port