Unverified Commit 52994701 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #67719 from liggitt/cloudstack-hostname

Automatic merge from submit-queue (batch tested with PRs 67447, 67719). 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>. Report cloudstack hostname address Cloud providers are now authoritative for the addresses reported by the kubelet. Cloud providers that have hostname information available via metadata should report it for use by the apiserver ```release-note The cloudstack cloud provider now reports a `Hostname` address type for nodes based on the `local-hostname` metadata key. ```
parents bb70b951 7078bfed
...@@ -69,6 +69,10 @@ func (cs *CSCloud) nodeAddresses(instance *cloudstack.VirtualMachine) ([]v1.Node ...@@ -69,6 +69,10 @@ func (cs *CSCloud) nodeAddresses(instance *cloudstack.VirtualMachine) ([]v1.Node
{Type: v1.NodeInternalIP, Address: instance.Nic[0].Ipaddress}, {Type: v1.NodeInternalIP, Address: instance.Nic[0].Ipaddress},
} }
if instance.Hostname != "" {
addresses = append(addresses, v1.NodeAddress{Type: v1.NodeHostName, Address: instance.Hostname})
}
if instance.Publicip != "" { if instance.Publicip != "" {
addresses = append(addresses, v1.NodeAddress{Type: v1.NodeExternalIP, Address: instance.Publicip}) addresses = append(addresses, v1.NodeAddress{Type: v1.NodeExternalIP, Address: instance.Publicip})
} else { } else {
......
...@@ -39,6 +39,7 @@ type metadata struct { ...@@ -39,6 +39,7 @@ type metadata struct {
type metadataType string type metadataType string
const ( const (
metadataTypeHostname metadataType = "local-hostname"
metadataTypeExternalIP metadataType = "public-ipv4" metadataTypeExternalIP metadataType = "public-ipv4"
metadataTypeInternalIP metadataType = "local-ipv4" metadataTypeInternalIP metadataType = "local-ipv4"
metadataTypeInstanceID metadataType = "instance-id" metadataTypeInstanceID metadataType = "instance-id"
...@@ -58,10 +59,20 @@ func (m *metadata) NodeAddresses(ctx context.Context, name types.NodeName) ([]v1 ...@@ -58,10 +59,20 @@ func (m *metadata) NodeAddresses(ctx context.Context, name types.NodeName) ([]v1
return nil, fmt.Errorf("could not get internal IP: %v", err) return nil, fmt.Errorf("could not get internal IP: %v", err)
} }
return []v1.NodeAddress{ addresses := []v1.NodeAddress{
{Type: v1.NodeExternalIP, Address: externalIP}, {Type: v1.NodeExternalIP, Address: externalIP},
{Type: v1.NodeInternalIP, Address: internalIP}, {Type: v1.NodeInternalIP, Address: internalIP},
}, nil }
hostname, err := m.get(metadataTypeHostname)
if err != nil {
return nil, fmt.Errorf("could not get hostname: %v", err)
}
if hostname != "" {
addresses = append(addresses, v1.NodeAddress{Type: v1.NodeHostName, Address: hostname})
}
return addresses, nil
} }
// NodeAddressesByProviderID returns the addresses of the specified instance. // NodeAddressesByProviderID returns the addresses of the specified instance.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment