Skip to content

Commit

Permalink
Global Default Address Pool feature support
Browse files Browse the repository at this point in the history
This feature brings new attribute/option for swarm init command.
default-addr-pool will take string input which can be in below format.
"CIDR,CIDR,CIDR...:SUBNET-SIZE".

Signed-off-by: selansen <elango.siva@docker.com>
  • Loading branch information
selansen committed Jul 25, 2018
1 parent c8b9c21 commit e0e150b
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 1 deletion.
3 changes: 3 additions & 0 deletions cli/command/swarm/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type initOptions struct {
dataPathAddr string
forceNewCluster bool
availability string
defaultAddrPool string
}

func newInitCommand(dockerCli command.Cli) *cobra.Command {
Expand All @@ -44,6 +45,7 @@ func newInitCommand(dockerCli command.Cli) *cobra.Command {
flags.BoolVar(&opts.forceNewCluster, "force-new-cluster", false, "Force create a new cluster from current state")
flags.BoolVar(&opts.autolock, flagAutolock, false, "Enable manager autolocking (requiring an unlock key to start a stopped manager)")
flags.StringVar(&opts.availability, flagAvailability, "active", `Availability of the node ("active"|"pause"|"drain")`)
flags.StringVar(&opts.defaultAddrPool, flagDefaultAddrPool, "", "List of default subnet addresses followed by subnet size (format: <subnet,subnet,..:subnet-size)")
addSwarmFlags(flags, &opts.swarmOptions)
return cmd
}
Expand All @@ -56,6 +58,7 @@ func runInit(dockerCli command.Cli, flags *pflag.FlagSet, opts initOptions) erro
ListenAddr: opts.listenAddr.String(),
AdvertiseAddr: opts.advertiseAddr,
DataPathAddr: opts.dataPathAddr,
DefaultAddrPool: opts.defaultAddrPool,
ForceNewCluster: opts.forceNewCluster,
Spec: opts.swarmOptions.ToSpec(flags),
AutoLockManagers: opts.swarmOptions.autolock,
Expand Down
1 change: 1 addition & 0 deletions cli/command/swarm/opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const (
flagListenAddr = "listen-addr"
flagAdvertiseAddr = "advertise-addr"
flagDataPathAddr = "data-path-addr"
flagDefaultAddrPool = "default-addr-pool"
flagQuiet = "quiet"
flagRotate = "rotate"
flagToken = "token"
Expand Down
6 changes: 5 additions & 1 deletion contrib/completion/bash/docker
Original file line number Diff line number Diff line change
Expand Up @@ -3667,6 +3667,10 @@ _docker_swarm_init() {
__docker_complete_local_interfaces
return
;;
--default-addr-pool)
COMPREPLY=( $( compgen -W "list of subnet addresses followed by subnet size" -- "$cur" ) )
return
;;
--listen-addr)
if [[ $cur == *: ]] ; then
COMPREPLY=( $( compgen -W "2377" -- "${cur##*:}" ) )
Expand All @@ -3680,7 +3684,7 @@ _docker_swarm_init() {

case "$cur" in
-*)
COMPREPLY=( $( compgen -W "--advertise-addr --autolock --availability --cert-expiry --data-path-addr --dispatcher-heartbeat --external-ca --force-new-cluster --help --listen-addr --max-snapshots --snapshot-interval --task-history-limit" -- "$cur" ) )
COMPREPLY=( $( compgen -W "--advertise-addr --autolock --availability --cert-expiry --data-path-addr --default-addr-pool --dispatcher-heartbeat --external-ca --force-new-cluster --help --listen-addr --max-snapshots --snapshot-interval --task-history-limit" -- "$cur" ) )
;;
esac
}
Expand Down
1 change: 1 addition & 0 deletions contrib/completion/zsh/_docker
Original file line number Diff line number Diff line change
Expand Up @@ -2280,6 +2280,7 @@ __docker_swarm_subcommand() {
$opts_help \
"($help)--advertise-addr=[Advertised address]:ip\:port: " \
"($help)--data-path-addr=[Data path IP or interface]:ip " \
"($help)--default-addr-pool=[default subnet addresses]:subnet-size " \
"($help)--autolock[Enable manager autolocking]" \
"($help)--availability=[Availability of the node]:availability:(active drain pause)" \
"($help)--cert-expiry=[Validity period for node certificates]:duration: " \
Expand Down
6 changes: 6 additions & 0 deletions docs/reference/commandline/swarm_init.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Options:
--availability string Availability of the node ("active"|"pause"|"drain") (default "active")
--cert-expiry duration Validity period for node certificates (ns|us|ms|s|m|h) (default 2160h0m0s)
--data-path-addr string Address or interface to use for data path traffic (format: <ip|interface>)
--default-addr-pool string List of default subnet addresses followed by subnet size (format: <subnet,subnet,..:subnet-size)
--dispatcher-heartbeat duration Dispatcher heartbeat period (ns|us|ms|s|m|h) (default 5s)
--external-ca external-ca Specifications of one or more certificate signing endpoints
--force-new-cluster Force create a new cluster from current state
Expand Down Expand Up @@ -128,6 +129,11 @@ management traffic of the cluster.
If unspecified, Docker will use the same IP address or interface that is used for the
advertise address.

### `--default-addr-pool`
This flag specifies default subnet pools for global scope networks. If subnet size is not
specified then default value 24 will be used.
If unspecified, Docker will use the predefined subnets as it works on older releases.

### `--task-history-limit`

This flag sets up task history retention limit.
Expand Down
1 change: 1 addition & 0 deletions vendor/github.com/docker/docker/api/types/swarm/swarm.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e0e150b

Please sign in to comment.