No DNS in vagrant cross minions, need explicit IP as host

This commit is contained in:
derekwaynecarr
2014-09-11 13:38:46 -04:00
parent 7de0989a4e
commit 0c20fffa06
5 changed files with 14 additions and 11 deletions

View File

@@ -106,8 +106,8 @@ func (v *VagrantCloud) IPAddress(instance string) (net.IP, error) {
}
filteredMinions := v.saltMinionsByRole(minions, "kubernetes-pool")
for _, minion := range filteredMinions {
fmt.Println("Minion: ", minion.Host, " , ", instance, " IP: ", minion.IP)
if minion.Host == instance {
// Due to vagrant not running with a dedicated DNS setup, we return the IP address of a minion as its hostname at this time
if minion.IP == instance {
return net.ParseIP(minion.IP), nil
}
}
@@ -203,7 +203,8 @@ func (v *VagrantCloud) List(filter string) ([]string, error) {
filteredMinions := v.saltMinionsByRole(minions, "kubernetes-pool")
var instances []string
for _, instance := range filteredMinions {
instances = append(instances, instance.Host)
// With no dedicated DNS setup in cluster, IP address is used as hostname
instances = append(instances, instance.IP)
}
return instances, nil

View File

@@ -73,7 +73,11 @@ func TestVagrantCloud(t *testing.T) {
t.Fatalf("Incorrect number of instances returned")
}
if instances[0] != "kubernetes-minion-1" {
// no DNS in vagrant cluster, so we return IP as hostname
expectedInstanceHost := "10.245.2.2"
expectedInstanceIP := "10.245.2.2"
if instances[0] != expectedInstanceHost {
t.Fatalf("Invalid instance returned")
}
@@ -82,7 +86,7 @@ func TestVagrantCloud(t *testing.T) {
t.Fatalf("Unexpected error, should have returned a valid IP address: %s", err)
}
if ip.String() != "10.245.2.2" {
if ip.String() != expectedInstanceIP {
t.Fatalf("Invalid IP address returned")
}
}