mirror of https://github.com/k3s-io/k3s
Make OpenStack cloud provider report a node hostname address
Related to: #67714 Cloud-provider-reported addresses are authoritative in 1.12, this preserves default behavior that used the internal dns name as the "Hostname" address on Node status.pull/8/head
parent
687553a47a
commit
641693ad05
|
@ -54,6 +54,9 @@ import (
|
||||||
const (
|
const (
|
||||||
// ProviderName is the name of the openstack provider
|
// ProviderName is the name of the openstack provider
|
||||||
ProviderName = "openstack"
|
ProviderName = "openstack"
|
||||||
|
|
||||||
|
// TypeHostName is the name type of openstack instance
|
||||||
|
TypeHostName = "hostname"
|
||||||
availabilityZone = "availability_zone"
|
availabilityZone = "availability_zone"
|
||||||
defaultTimeOut = 60 * time.Second
|
defaultTimeOut = 60 * time.Second
|
||||||
)
|
)
|
||||||
|
@ -498,6 +501,15 @@ func nodeAddresses(srv *servers.Server) ([]v1.NodeAddress, error) {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if srv.Metadata[TypeHostName] != "" {
|
||||||
|
v1helper.AddToNodeAddresses(&addrs,
|
||||||
|
v1.NodeAddress{
|
||||||
|
Type: v1.NodeHostName,
|
||||||
|
Address: srv.Metadata[TypeHostName],
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
return addrs, nil
|
return addrs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -444,6 +444,10 @@ func TestNodeAddresses(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Metadata: map[string]string{
|
||||||
|
"name": "a1-yinvcez57-0-bvynoyawrhcg-kube-minion-fg5i4jwcc2yy",
|
||||||
|
TypeHostName: "a1-yinvcez57-0-bvynoyawrhcg-kube-minion-fg5i4jwcc2yy.novalocal",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
addrs, err := nodeAddresses(&srv)
|
addrs, err := nodeAddresses(&srv)
|
||||||
|
@ -462,6 +466,7 @@ func TestNodeAddresses(t *testing.T) {
|
||||||
{Type: v1.NodeExternalIP, Address: "50.56.176.35"},
|
{Type: v1.NodeExternalIP, Address: "50.56.176.35"},
|
||||||
{Type: v1.NodeExternalIP, Address: "50.56.176.36"},
|
{Type: v1.NodeExternalIP, Address: "50.56.176.36"},
|
||||||
{Type: v1.NodeExternalIP, Address: "50.56.176.99"},
|
{Type: v1.NodeExternalIP, Address: "50.56.176.99"},
|
||||||
|
{Type: v1.NodeHostName, Address: "a1-yinvcez57-0-bvynoyawrhcg-kube-minion-fg5i4jwcc2yy.novalocal"},
|
||||||
}
|
}
|
||||||
|
|
||||||
if !reflect.DeepEqual(want, addrs) {
|
if !reflect.DeepEqual(want, addrs) {
|
||||||
|
|
Loading…
Reference in New Issue