mirror of https://github.com/docker/docs.git
Merge pull request #858 from aluzzardi/addr-flag
Replace --addr with --advertise
This commit is contained in:
commit
23f66f8cc6
|
@ -114,7 +114,7 @@ func Run() {
|
||||||
flStore,
|
flStore,
|
||||||
flStrategy, flFilter,
|
flStrategy, flFilter,
|
||||||
flHosts,
|
flHosts,
|
||||||
flLeaderElection, flAddr,
|
flLeaderElection, flManageAdvertise,
|
||||||
flTLS, flTLSCaCert, flTLSCert, flTLSKey, flTLSVerify,
|
flTLS, flTLSCaCert, flTLSCert, flTLSKey, flTLSVerify,
|
||||||
flHeartBeat,
|
flHeartBeat,
|
||||||
flEnableCors,
|
flEnableCors,
|
||||||
|
@ -125,7 +125,7 @@ func Run() {
|
||||||
Name: "join",
|
Name: "join",
|
||||||
ShortName: "j",
|
ShortName: "j",
|
||||||
Usage: "join a docker cluster",
|
Usage: "join a docker cluster",
|
||||||
Flags: []cli.Flag{flAddr, flHeartBeat, flTTL},
|
Flags: []cli.Flag{flJoinAdvertise, flHeartBeat, flTTL},
|
||||||
Action: join,
|
Action: join,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
15
cli/flags.go
15
cli/flags.go
|
@ -32,13 +32,16 @@ var (
|
||||||
Value: homepath(".swarm"),
|
Value: homepath(".swarm"),
|
||||||
Usage: "",
|
Usage: "",
|
||||||
}
|
}
|
||||||
flAddr = cli.StringFlag{
|
flJoinAdvertise = cli.StringFlag{
|
||||||
Name: "addr",
|
Name: "advertise, addr",
|
||||||
Value: "127.0.0.1:2375",
|
Usage: "Address of the Docker Engine joining the cluster. Swarm managers MUST be able to reach Docker at this address.",
|
||||||
Usage: "ip to advertise",
|
EnvVar: "SWARM_ADVERTISE",
|
||||||
EnvVar: "SWARM_ADDR",
|
}
|
||||||
|
flManageAdvertise = cli.StringFlag{
|
||||||
|
Name: "advertise, addr",
|
||||||
|
Usage: "Address of the Swarm manager joining the cluster. Other swarm managers MUST be able to reach Swarm at this address.",
|
||||||
|
EnvVar: "SWARM_ADVERTISE",
|
||||||
}
|
}
|
||||||
|
|
||||||
// hack for go vet
|
// hack for go vet
|
||||||
flHostsValue = cli.StringSlice([]string{"tcp://127.0.0.1:2375"})
|
flHostsValue = cli.StringSlice([]string{"tcp://127.0.0.1:2375"})
|
||||||
|
|
||||||
|
|
14
cli/join.go
14
cli/join.go
|
@ -20,6 +20,14 @@ func join(c *cli.Context) {
|
||||||
log.Fatalf("discovery required to join a cluster. See '%s join --help'.", c.App.Name)
|
log.Fatalf("discovery required to join a cluster. See '%s join --help'.", c.App.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addr := c.String("advertise")
|
||||||
|
if addr == "" {
|
||||||
|
log.Fatal("missing mandatory --advertise flag")
|
||||||
|
}
|
||||||
|
if !checkAddrFormat(addr) {
|
||||||
|
log.Fatal("--advertise should be of the form ip:port or hostname:port")
|
||||||
|
}
|
||||||
|
|
||||||
hb, err := time.ParseDuration(c.String("heartbeat"))
|
hb, err := time.ParseDuration(c.String("heartbeat"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("invalid --heartbeat: %v", err)
|
log.Fatalf("invalid --heartbeat: %v", err)
|
||||||
|
@ -39,12 +47,6 @@ func join(c *cli.Context) {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
addr := c.String("addr")
|
|
||||||
|
|
||||||
if !checkAddrFormat(addr) {
|
|
||||||
log.Fatal("--addr should be of the form ip:port or hostname:port")
|
|
||||||
}
|
|
||||||
|
|
||||||
for {
|
for {
|
||||||
log.WithFields(log.Fields{"addr": addr, "discovery": dflag}).Infof("Registering on the discovery service every %s...", hb)
|
log.WithFields(log.Fields{"addr": addr, "discovery": dflag}).Infof("Registering on the discovery service every %s...", hb)
|
||||||
if err := d.Register(addr); err != nil {
|
if err := d.Register(addr); err != nil {
|
||||||
|
|
|
@ -211,7 +211,15 @@ func manage(c *cli.Context) {
|
||||||
router := api.NewRouter(cl, tlsConfig, c.Bool("cors"))
|
router := api.NewRouter(cl, tlsConfig, c.Bool("cors"))
|
||||||
|
|
||||||
if c.Bool("leader-election") {
|
if c.Bool("leader-election") {
|
||||||
setupLeaderElection(server, router, discovery, c.String("addr"), tlsConfig)
|
addr := c.String("advertise")
|
||||||
|
if addr == "" {
|
||||||
|
log.Fatal("--advertise address must be provided when using --leader-election")
|
||||||
|
}
|
||||||
|
if !checkAddrFormat(addr) {
|
||||||
|
log.Fatal("--advertise should be of the form ip:port or hostname:port")
|
||||||
|
}
|
||||||
|
|
||||||
|
setupLeaderElection(server, router, discovery, addr, tlsConfig)
|
||||||
} else {
|
} else {
|
||||||
server.SetHandler(router)
|
server.SetHandler(router)
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ Then we create each node and join them to the cluster.
|
||||||
# on each of your nodes, start the swarm agent
|
# on each of your nodes, start the swarm agent
|
||||||
# <node_ip> doesn't have to be public (eg. 192.168.0.X),
|
# <node_ip> doesn't have to be public (eg. 192.168.0.X),
|
||||||
# as long as the swarm manager can access it.
|
# as long as the swarm manager can access it.
|
||||||
$ swarm join --addr=<node_ip:2375> token://<cluster_id>
|
$ swarm join --advertise=<node_ip:2375> token://<cluster_id>
|
||||||
```
|
```
|
||||||
|
|
||||||
Finally, we start the Swarm manager. This can be on any machine or even
|
Finally, we start the Swarm manager. This can be on any machine or even
|
||||||
|
@ -95,7 +95,7 @@ On each of your nodes, start the Swarm agent. The node IP address
|
||||||
doesn't have to be public as long as the swarm manager can access it.
|
doesn't have to be public as long as the swarm manager can access it.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
swarm join --addr=<node_ip:2375> etcd://<etcd_ip>/<path>
|
swarm join --advertise=<node_ip:2375> etcd://<etcd_ip>/<path>
|
||||||
```
|
```
|
||||||
|
|
||||||
Start the manager on any machine or your laptop.
|
Start the manager on any machine or your laptop.
|
||||||
|
@ -127,7 +127,7 @@ On each of your nodes, start the Swarm agent. The node IP address
|
||||||
doesn't need to be public as long as the Swarm manager can access it.
|
doesn't need to be public as long as the Swarm manager can access it.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
swarm join --addr=<node_ip:2375> consul://<consul_addr>/<path>
|
swarm join --advertise=<node_ip:2375> consul://<consul_addr>/<path>
|
||||||
```
|
```
|
||||||
|
|
||||||
Start the manager on any machine or your laptop.
|
Start the manager on any machine or your laptop.
|
||||||
|
@ -159,7 +159,7 @@ On each of your nodes, start the Swarm agent. The node IP doesn't have
|
||||||
to be public as long as the swarm manager can access it.
|
to be public as long as the swarm manager can access it.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
swarm join --addr=<node_ip:2375> zk://<zookeeper_addr1>,<zookeeper_addr2>/<path>
|
swarm join --advertise=<node_ip:2375> zk://<zookeeper_addr1>,<zookeeper_addr2>/<path>
|
||||||
```
|
```
|
||||||
|
|
||||||
Start the manager on any machine or your laptop.
|
Start the manager on any machine or your laptop.
|
||||||
|
|
|
@ -26,7 +26,7 @@ Then we create each node and join them to the cluster.
|
||||||
# on each of your nodes, start the swarm agent
|
# on each of your nodes, start the swarm agent
|
||||||
# <node_ip> doesn't have to be public (eg. 192.168.0.X),
|
# <node_ip> doesn't have to be public (eg. 192.168.0.X),
|
||||||
# as long as the swarm manager can access it.
|
# as long as the swarm manager can access it.
|
||||||
$ swarm join --addr=<node_ip:2375> token://<cluster_id>
|
$ swarm join --advertise=<node_ip:2375> token://<cluster_id>
|
||||||
```
|
```
|
||||||
|
|
||||||
Finally, we start the Swarm manager. This can be on any machine or even
|
Finally, we start the Swarm manager. This can be on any machine or even
|
||||||
|
@ -95,7 +95,7 @@ On each of your nodes, start the Swarm agent. The node IP address
|
||||||
doesn't have to be public as long as the swarm manager can access it.
|
doesn't have to be public as long as the swarm manager can access it.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
swarm join --addr=<node_ip:2375> etcd://<etcd_addr1>,<etcd_addr2>/<optional path prefix>
|
swarm join --advertise=<node_ip:2375> etcd://<etcd_addr1>,<etcd_addr2>/<optional path prefix>
|
||||||
```
|
```
|
||||||
|
|
||||||
Start the manager on any machine or your laptop.
|
Start the manager on any machine or your laptop.
|
||||||
|
@ -127,7 +127,7 @@ On each of your nodes, start the Swarm agent. The node IP address
|
||||||
doesn't need to be public as long as the Swarm manager can access it.
|
doesn't need to be public as long as the Swarm manager can access it.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
swarm join --addr=<node_ip:2375> consul://<consul_addr>/<optional path prefix>
|
swarm join --advertise=<node_ip:2375> consul://<consul_addr>/<optional path prefix>
|
||||||
```
|
```
|
||||||
|
|
||||||
Start the manager on any machine or your laptop.
|
Start the manager on any machine or your laptop.
|
||||||
|
@ -159,7 +159,7 @@ On each of your nodes, start the Swarm agent. The node IP doesn't have
|
||||||
to be public as long as the swarm manager can access it.
|
to be public as long as the swarm manager can access it.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
swarm join --addr=<node_ip:2375> zk://<zookeeper_addr1>,<zookeeper_addr2>/<optional path prefix>
|
swarm join --advertise=<node_ip:2375> zk://<zookeeper_addr1>,<zookeeper_addr2>/<optional path prefix>
|
||||||
```
|
```
|
||||||
|
|
||||||
Start the manager on any machine or your laptop.
|
Start the manager on any machine or your laptop.
|
||||||
|
|
|
@ -41,14 +41,14 @@ For instance, let's start `node-1` with the `storage=ssd` label:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ docker -d --label storage=ssd
|
$ docker -d --label storage=ssd
|
||||||
$ swarm join --addr=192.168.0.42:2375 token://XXXXXXXXXXXXXXXXXX
|
$ swarm join --advertise=192.168.0.42:2375 token://XXXXXXXXXXXXXXXXXX
|
||||||
```
|
```
|
||||||
|
|
||||||
Again, but this time `node-2` with `storage=disk`:
|
Again, but this time `node-2` with `storage=disk`:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ docker -d --label storage=disk
|
$ docker -d --label storage=disk
|
||||||
$ swarm join --addr=192.168.0.43:2375 token://XXXXXXXXXXXXXXXXXX
|
$ swarm join --advertise=192.168.0.43:2375 token://XXXXXXXXXXXXXXXXXX
|
||||||
```
|
```
|
||||||
|
|
||||||
Once the nodes are registered with the cluster, the master pulls their respective
|
Once the nodes are registered with the cluster, the master pulls their respective
|
||||||
|
|
|
@ -41,14 +41,14 @@ For instance, let's start `node-1` with the `storage=ssd` label:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ docker -d --label storage=ssd
|
$ docker -d --label storage=ssd
|
||||||
$ swarm join --addr=192.168.0.42:2375 token://XXXXXXXXXXXXXXXXXX
|
$ swarm join --advertise=192.168.0.42:2375 token://XXXXXXXXXXXXXXXXXX
|
||||||
```
|
```
|
||||||
|
|
||||||
Again, but this time `node-2` with `storage=disk`:
|
Again, but this time `node-2` with `storage=disk`:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ docker -d --label storage=disk
|
$ docker -d --label storage=disk
|
||||||
$ swarm join --addr=192.168.0.43:2375 token://XXXXXXXXXXXXXXXXXX
|
$ swarm join --advertise=192.168.0.43:2375 token://XXXXXXXXXXXXXXXXXX
|
||||||
```
|
```
|
||||||
|
|
||||||
Once the nodes are registered with the cluster, the master pulls their respective
|
Once the nodes are registered with the cluster, the master pulls their respective
|
||||||
|
|
|
@ -117,7 +117,7 @@ function swarm_join() {
|
||||||
for ((i=current; i < nodes; i++)); do
|
for ((i=current; i < nodes; i++)); do
|
||||||
local h="${HOSTS[$i]}"
|
local h="${HOSTS[$i]}"
|
||||||
echo "Swarm join #${i}: $h $addr"
|
echo "Swarm join #${i}: $h $addr"
|
||||||
"$SWARM_BINARY" -l debug join --heartbeat=1s --ttl=10s --addr="$h" "$addr" &
|
"$SWARM_BINARY" -l debug join --heartbeat=1s --ttl=10s --advertise="$h" "$addr" &
|
||||||
SWARM_JOIN_PID[$i]=$!
|
SWARM_JOIN_PID[$i]=$!
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue