Merge pull request #67715 from liggitt/aws-hostname
Automatic merge from submit-queue (batch tested with PRs 66980, 67604, 67741, 67715). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Make aws cloud provider report a node hostname address 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 /sig aws /sig cloud-provider ```release-note The aws cloud provider now reports a `Hostname` address type for nodes based on the `local-hostname` metadata key. ```
This commit is contained in:
commit
f15fe93384
@ -1245,6 +1245,7 @@ func (c *Cloud) NodeAddresses(ctx context.Context, name types.NodeName) ([]v1.No
|
||||
glog.V(4).Info("Could not determine private DNS from AWS metadata.")
|
||||
} else {
|
||||
addresses = append(addresses, v1.NodeAddress{Type: v1.NodeInternalDNS, Address: internalDNS})
|
||||
addresses = append(addresses, v1.NodeAddress{Type: v1.NodeHostName, Address: internalDNS})
|
||||
}
|
||||
|
||||
externalDNS, err := c.metadata.GetMetadata("public-hostname")
|
||||
@ -1307,6 +1308,7 @@ func extractNodeAddresses(instance *ec2.Instance) ([]v1.NodeAddress, error) {
|
||||
privateDNSName := aws.StringValue(instance.PrivateDnsName)
|
||||
if privateDNSName != "" {
|
||||
addresses = append(addresses, v1.NodeAddress{Type: v1.NodeInternalDNS, Address: privateDNSName})
|
||||
addresses = append(addresses, v1.NodeAddress{Type: v1.NodeHostName, Address: privateDNSName})
|
||||
}
|
||||
|
||||
publicDNSName := aws.StringValue(instance.PublicDnsName)
|
||||
|
@ -348,13 +348,14 @@ func TestNodeAddresses(t *testing.T) {
|
||||
if err3 != nil {
|
||||
t.Errorf("Should not error when instance found")
|
||||
}
|
||||
if len(addrs3) != 4 {
|
||||
t.Errorf("Should return exactly 4 NodeAddresses")
|
||||
if len(addrs3) != 5 {
|
||||
t.Errorf("Should return exactly 5 NodeAddresses")
|
||||
}
|
||||
testHasNodeAddress(t, addrs3, v1.NodeInternalIP, "192.168.0.1")
|
||||
testHasNodeAddress(t, addrs3, v1.NodeExternalIP, "1.2.3.4")
|
||||
testHasNodeAddress(t, addrs3, v1.NodeExternalDNS, "instance-same.ec2.external")
|
||||
testHasNodeAddress(t, addrs3, v1.NodeInternalDNS, "instance-same.ec2.internal")
|
||||
testHasNodeAddress(t, addrs3, v1.NodeHostName, "instance-same.ec2.internal")
|
||||
}
|
||||
|
||||
func TestNodeAddressesWithMetadata(t *testing.T) {
|
||||
|
Loading…
Reference in New Issue
Block a user