Skip to content
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
5 changes: 5 additions & 0 deletions pkg/cmd/server/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ func (cfg Config) GetEtcdBindAddress() string {
return net.JoinHostPort(cfg.BindAddr.Host, strconv.Itoa(cfg.EtcdAddr.DefaultPort))
}

func (cfg Config) GetEtcdPeerBindAddress() string {
// Derive the etcd peer address by using the bind address and the default etcd peering port
return net.JoinHostPort(cfg.BindAddr.Host, "7001")
}

func (cfg Config) GetEtcdAddress() (*url.URL, error) {
if cfg.EtcdAddr.Provided {
return cfg.EtcdAddr.URL, nil
Expand Down
10 changes: 10 additions & 0 deletions pkg/cmd/server/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,16 @@ func TestEtcdBindAddressDefault(t *testing.T) {
}
}

func TestEtcdPeerAddressDefault(t *testing.T) {
expected := "0.0.0.0:7001"

cfg := NewDefaultConfig()
actual := cfg.GetEtcdPeerBindAddress()
if expected != actual {
t.Errorf("expected %v, got %v", expected, actual)
}
}

func TestEtcdBindAddressDefaultToBind(t *testing.T) {
expected := "1.2.3.4:4001"

Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/server/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func (cfg Config) RunEtcd() error {

etcdConfig := &etcd.Config{
BindAddr: cfg.GetEtcdBindAddress(),
PeerBindAddr: cfg.GetEtcdBindAddress(),
PeerBindAddr: cfg.GetEtcdPeerBindAddress(),
MasterAddr: etcdAddr.Host,
EtcdDir: cfg.EtcdDir,
}
Expand Down