mirror of https://github.com/docker/cli.git
Data Path Port configuration support
This PR chnages allow user to configure data path port number. By default we use 4789 port number. But this commit will allow user to configure port number during swarm init. Data path port can't be modified after swarm init. Signed-off-by: selansen <elango.siva@docker.com>
This commit is contained in:
parent
052133a4f5
commit
e3e976a82a
|
@ -20,6 +20,7 @@ type initOptions struct {
|
|||
// Not a NodeAddrOption because it has no default port.
|
||||
advertiseAddr string
|
||||
dataPathAddr string
|
||||
dataPathPort uint32
|
||||
forceNewCluster bool
|
||||
availability string
|
||||
defaultAddrPools []net.IPNet
|
||||
|
@ -45,6 +46,8 @@ func newInitCommand(dockerCli command.Cli) *cobra.Command {
|
|||
flags.StringVar(&opts.advertiseAddr, flagAdvertiseAddr, "", "Advertised address (format: <ip|interface>[:port])")
|
||||
flags.StringVar(&opts.dataPathAddr, flagDataPathAddr, "", "Address or interface to use for data path traffic (format: <ip|interface>)")
|
||||
flags.SetAnnotation(flagDataPathAddr, "version", []string{"1.31"})
|
||||
flags.Uint32Var(&opts.dataPathPort, flagDataPathPort, 0, "Port number to use for data path traffic (1024 - 49151). If no value is set or is set to 0, the default port (4789) is used.")
|
||||
flags.SetAnnotation(flagDataPathPort, "version", []string{"1.40"})
|
||||
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")`)
|
||||
|
@ -69,6 +72,7 @@ func runInit(dockerCli command.Cli, flags *pflag.FlagSet, opts initOptions) erro
|
|||
ListenAddr: opts.listenAddr.String(),
|
||||
AdvertiseAddr: opts.advertiseAddr,
|
||||
DataPathAddr: opts.dataPathAddr,
|
||||
DataPathPort: opts.dataPathPort,
|
||||
DefaultAddrPool: defaultAddrPool,
|
||||
ForceNewCluster: opts.forceNewCluster,
|
||||
Spec: opts.swarmOptions.ToSpec(flags),
|
||||
|
|
|
@ -22,6 +22,7 @@ const (
|
|||
flagListenAddr = "listen-addr"
|
||||
flagAdvertiseAddr = "advertise-addr"
|
||||
flagDataPathAddr = "data-path-addr"
|
||||
flagDataPathPort = "data-path-port"
|
||||
flagDefaultAddrPool = "default-addr-pool"
|
||||
flagDefaultAddrPoolMaskLength = "default-addr-pool-mask-length"
|
||||
flagQuiet = "quiet"
|
||||
|
|
|
@ -235,6 +235,9 @@ func printSwarmInfo(dockerCli command.Cli, info types.Info) {
|
|||
fmt.Fprintln(dockerCli.Out(), " Default Address Pool:", strAddrPool.String())
|
||||
fmt.Fprintln(dockerCli.Out(), " SubnetSize:", info.Swarm.Cluster.SubnetSize)
|
||||
}
|
||||
if info.Swarm.Cluster.DataPathPort > 0 {
|
||||
fmt.Fprintln(dockerCli.Out(), " Data Path Port:", info.Swarm.Cluster.DataPathPort)
|
||||
}
|
||||
fmt.Fprintln(dockerCli.Out(), " Orchestration:")
|
||||
|
||||
taskHistoryRetentionLimit := int64(0)
|
||||
|
|
|
@ -3698,7 +3698,7 @@ _docker_swarm_init() {
|
|||
COMPREPLY=( $( compgen -W "active drain pause" -- "$cur" ) )
|
||||
return
|
||||
;;
|
||||
--cert-expiry|--default-addr-pool|--default-addr-pool-mask-length|--dispatcher-heartbeat|--external-ca|--max-snapshots|--snapshot-interval|--task-history-limit )
|
||||
--cert-expiry|--data-path-port|--default-addr-pool|--default-addr-pool-mask-length|--dispatcher-heartbeat|--external-ca|--max-snapshots|--snapshot-interval|--task-history-limit )
|
||||
return
|
||||
;;
|
||||
--data-path-addr)
|
||||
|
@ -3718,7 +3718,7 @@ _docker_swarm_init() {
|
|||
|
||||
case "$cur" in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W "--advertise-addr --autolock --availability --cert-expiry --data-path-addr --default-addr-pool --default-addr-pool-mask-length --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 --data-path-port --default-addr-pool --default-addr-pool-mask-length --dispatcher-heartbeat --external-ca --force-new-cluster --help --listen-addr --max-snapshots --snapshot-interval --task-history-limit " -- "$cur" ) )
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
|
|
@ -2285,6 +2285,7 @@ __docker_swarm_subcommand() {
|
|||
$opts_help \
|
||||
"($help)--advertise-addr=[Advertised address]:ip\:port: " \
|
||||
"($help)--data-path-addr=[Data path IP or interface]:ip " \
|
||||
"($help)--data-path-port=[Data Path Port]:port " \
|
||||
"($help)--default-addr-pool=[Default address pool]" \
|
||||
"($help)--default-addr-pool-mask-length=[Default address pool subnet mask length]" \
|
||||
"($help)--autolock[Enable manager autolocking]" \
|
||||
|
|
|
@ -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>)
|
||||
--data-path-port uint32 Port number to use for data path traffic (1024 - 49151). If no value is set or is set to 0, the default port (4789) is used.
|
||||
--default-addr-pool IPnet List of default address pool (format: <cidr>)
|
||||
--default-addr-pool-mask-length Subnet mask length for default address pool (default 24)
|
||||
--dispatcher-heartbeat duration Dispatcher heartbeat period (ns|us|ms|s|m|h) (default 5s)
|
||||
|
@ -130,6 +131,32 @@ management traffic of the cluster.
|
|||
If unspecified, Docker will use the same IP address or interface that is used for the
|
||||
advertise address.
|
||||
|
||||
### `--data-path-port`
|
||||
|
||||
This flag allows you to configure the UDP port number to use for data path
|
||||
traffic. The provided port number must be within the 1024 - 49151 range. If
|
||||
this flag is not set or is set to 0, the default port number 4789 is used.
|
||||
The data path port can only be configured when initializing the swarm, and
|
||||
applies to all nodes that join the swarm.
|
||||
The following example initializes a new Swarm, and configures the data path
|
||||
port to UDP port 7777;
|
||||
|
||||
```bash
|
||||
docker swarm init --data-path-port=7777
|
||||
```
|
||||
After the swarm is initialized, use the `docker info` command to verify that
|
||||
the port is configured:
|
||||
|
||||
```bash
|
||||
docker info
|
||||
...
|
||||
ClusterID: 9vs5ygs0gguyyec4iqf2314c0
|
||||
Managers: 1
|
||||
Nodes: 1
|
||||
Data Path Port: 7777
|
||||
...
|
||||
```
|
||||
|
||||
### `--default-addr-pool`
|
||||
This flag specifies default subnet pools for global scope networks.
|
||||
Format example is `--default-addr-pool 30.30.0.0/16 --default-addr-pool 40.40.0.0/16`
|
||||
|
|
Loading…
Reference in New Issue