mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 14:07:14 +00:00
Fix AWS kubelet registration.
This commit allows the AWS cloud provider plugin to work on EC2 instances that do not have a public IP. The EC2 metadata service returns a 404 for the 'public-ipv4' endpoint for private instances, and the plugin was bubbling this up as a fatal error.
This commit is contained in:
parent
9942f6bf3e
commit
adde7f548f
@ -650,19 +650,23 @@ func (aws *AWSCloud) NodeAddresses(name string) ([]api.NodeAddress, error) {
|
||||
return nil, err
|
||||
}
|
||||
if self.nodeName == name || len(name) == 0 {
|
||||
addresses := []api.NodeAddress{}
|
||||
|
||||
internalIP, err := aws.metadata.GetMetadata("local-ipv4")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
addresses = append(addresses, api.NodeAddress{Type: api.NodeInternalIP, Address: internalIP})
|
||||
addresses = append(addresses, api.NodeAddress{Type: api.NodeLegacyHostIP, Address: internalIP})
|
||||
|
||||
externalIP, err := aws.metadata.GetMetadata("public-ipv4")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
//Perhaps only log this as a warning the first time this method is called?
|
||||
} else {
|
||||
addresses = append(addresses, api.NodeAddress{Type: api.NodeExternalIP, Address: externalIP})
|
||||
}
|
||||
return []api.NodeAddress{
|
||||
{Type: api.NodeInternalIP, Address: internalIP},
|
||||
{Type: api.NodeLegacyHostIP, Address: internalIP},
|
||||
{Type: api.NodeExternalIP, Address: externalIP},
|
||||
}, nil
|
||||
|
||||
return addresses, nil
|
||||
}
|
||||
instance, err := aws.getInstanceByNodeName(name)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user