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 @@ -144,6 +144,11 @@ func (cfg Config) GetMasterPublicAddress() (*url.URL, error) {
return cfg.GetMasterAddress()
}

func (cfg Config) GetEtcdBindAddress() string {
// Derive the etcd bind address by using the bind address and the default etcd port
return net.JoinHostPort(cfg.BindAddr.Host, strconv.Itoa(cfg.EtcdAddr.DefaultPort))
}

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

func TestEtcdBindAddressDefault(t *testing.T) {
expected := "0.0.0.0:4001"

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

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

cfg := NewDefaultConfig()
cfg.BindAddr.Set("https://1.2.3.4:8080")

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

func TestMasterAddressDefaultingToBindValues(t *testing.T) {
defaultIP, err := util.DefaultLocalIP4()
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/server/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ func (cfg Config) RunEtcd() error {
}

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