Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make RPC, Serf LAN, Serf WAN port configurable from CLI #4353

Merged
merged 1 commit into from
Jul 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions agent/config/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func AddFlags(fs *flag.FlagSet, f *Flags) {
add(&f.Config.AdvertiseAddrLAN, "advertise", "Sets the advertise address to use.")
add(&f.Config.AdvertiseAddrWAN, "advertise-wan", "Sets address to advertise on WAN instead of -advertise address.")
add(&f.Config.BindAddr, "bind", "Sets the bind address for cluster communication.")
add(&f.Config.Ports.Server, "server-port", "Sets the server port to listen on.")
add(&f.Config.Bootstrap, "bootstrap", "Sets server to bootstrap mode.")
add(&f.Config.BootstrapExpect, "bootstrap-expect", "Sets server to expect bootstrap mode.")
add(&f.Config.ClientAddr, "client", "Sets the address to bind for client access. This includes RPC, DNS, HTTP and HTTPS (if configured).")
Expand Down Expand Up @@ -91,8 +92,10 @@ func AddFlags(fs *flag.FlagSet, f *Flags) {
add(&f.Config.RetryJoinMaxAttemptsLAN, "retry-max", "Maximum number of join attempts. Defaults to 0, which will retry indefinitely.")
add(&f.Config.RetryJoinMaxAttemptsWAN, "retry-max-wan", "Maximum number of join -wan attempts. Defaults to 0, which will retry indefinitely.")
add(&f.Config.SerfBindAddrLAN, "serf-lan-bind", "Address to bind Serf LAN listeners to.")
add(&f.Config.Ports.SerfLAN, "serf-lan-port", "Sets the Serf LAN port to listen on.")
add(&f.Config.SegmentName, "segment", "(Enterprise-only) Sets the network segment to join.")
add(&f.Config.SerfBindAddrWAN, "serf-wan-bind", "Address to bind Serf WAN listeners to.")
add(&f.Config.Ports.SerfWAN, "serf-wan-port", "Sets the Serf WAN port to listen on.")
add(&f.Config.ServerMode, "server", "Switches agent to server mode.")
add(&f.Config.EnableSyslog, "syslog", "Enables logging to syslog.")
add(&f.Config.UI, "ui", "Enables the built-in static web UI server.")
Expand Down
12 changes: 12 additions & 0 deletions agent/config/flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@ func TestParseFlags(t *testing.T) {
args: []string{`-dns-port`, `1`},
flags: Flags{Config: Config{Ports: Ports{DNS: pInt(1)}}},
},
{
args: []string{`-serf-lan-port`, `1`},
flags: Flags{Config: Config{Ports: Ports{SerfLAN: pInt(1)}}},
},
{
args: []string{`-serf-wan-port`, `1`},
flags: Flags{Config: Config{Ports: Ports{SerfWAN: pInt(1)}}},
},
{
args: []string{`-server-port`, `1`},
flags: Flags{Config: Config{Ports: Ports{Server: pInt(1)}}},
},
{
args: []string{`-join`, `a`, `-join`, `b`},
flags: Flags{Config: Config{StartJoinAddrsLAN: []string{"a", "b"}}},
Expand Down
39 changes: 39 additions & 0 deletions agent/config/runtime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,19 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
rt.DataDir = dataDir
},
},
{
desc: "-serf-lan-port",
args: []string{
`-serf-lan-port=123`,
`-data-dir=` + dataDir,
},
patch: func(rt *RuntimeConfig) {
rt.SerfPortLAN = 123
rt.SerfAdvertiseAddrLAN = tcpAddr("10.0.0.1:123")
rt.SerfBindAddrLAN = tcpAddr("0.0.0.0:123")
rt.DataDir = dataDir
},
},
{
desc: "-serf-wan-bind",
args: []string{
Expand All @@ -654,6 +667,19 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
rt.DataDir = dataDir
},
},
{
desc: "-serf-wan-port",
args: []string{
`-serf-wan-port=123`,
`-data-dir=` + dataDir,
},
patch: func(rt *RuntimeConfig) {
rt.SerfPortWAN = 123
rt.SerfAdvertiseAddrWAN = tcpAddr("10.0.0.1:123")
rt.SerfBindAddrWAN = tcpAddr("0.0.0.0:123")
rt.DataDir = dataDir
},
},
{
desc: "-server",
args: []string{
Expand All @@ -667,6 +693,19 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
rt.DataDir = dataDir
},
},
{
desc: "-server-port",
args: []string{
`-server-port=123`,
`-data-dir=` + dataDir,
},
patch: func(rt *RuntimeConfig) {
rt.ServerPort = 123
rt.RPCAdvertiseAddr = tcpAddr("10.0.0.1:123")
rt.RPCBindAddr = tcpAddr("0.0.0.0:123")
rt.DataDir = dataDir
},
},
{
desc: "-syslog",
args: []string{
Expand Down
9 changes: 9 additions & 0 deletions website/source/docs/agent/options.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,12 @@ will exit with an error at startup.
within its network segment. See the [Network Segments Guide](/docs/guides/segments.html) for more details.
By default, this is an empty string, which is the default network segment.

* <a name="_serf_lan_port"></a><a href="#_serf_lan_port">`-serf-lan-port`</a> - the Serf LAN port to listen on.
This overrides the default Serf LAN port 8301. This is available in Consul 1.2.2 and later.

* <a name="_serf_wan_port"></a><a href="#_serf_wan_port">`-serf-wan-port`</a> - the Serf WAN port to listen on.
This overrides the default Serf WAN port 8302. This is available in Consul 1.2.2 and later.

* <a name="_server"></a><a href="#_server">`-server`</a> - This flag is used to control if an
agent is in server or client mode. When provided,
an agent will act as a Consul server. Each Consul cluster must have at least one server and ideally
Expand All @@ -396,6 +402,9 @@ will exit with an error at startup.
participate in a WAN gossip pool with server nodes in other datacenters. Servers act as gateways
to other datacenters and forward traffic as appropriate.

* <a name="_server_port"></a><a href="#_server_port">`-server-port`</a> - the server RPC port to listen on.
This overrides the default server RPC port 8300. This is available in Consul 1.2.2 and later.

* <a name="_non_voting_server"></a><a href="#_non_voting_server">`-non-voting-server`</a> - (Enterprise-only)
This flag is used to make the server not participate in the Raft quorum, and have it only receive the data
replication stream. This can be used to add read scalability to a cluster in cases where a high volume of
Expand Down