mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 14:37:00 +00:00
use aws://[instance-id] as the ProviderID
This commit is contained in:
parent
baa85c830a
commit
bc9d2e8832
@ -69,7 +69,6 @@ func GetLoadBalancerName(service *v1.Service) string {
|
||||
}
|
||||
|
||||
// GetInstanceProviderID builds a ProviderID for a node in a cloud.
|
||||
// TODO: The name and placement of this method suggests that it is a canonical definition of ProviderID. This doesn't seem to be true. e.g. The AWS implementation uses undecorated InstanceID as the ProviderID.
|
||||
func GetInstanceProviderID(cloud Interface, nodeName types.NodeName) (string, error) {
|
||||
instances, ok := cloud.Instances()
|
||||
if !ok {
|
||||
|
@ -1037,8 +1037,11 @@ func (c *Cloud) NodeAddresses(name types.NodeName) ([]v1.NodeAddress, error) {
|
||||
// This method will not be called from the node that is requesting this ID. i.e. metadata service
|
||||
// and other local methods cannot be used here
|
||||
func (c *Cloud) NodeAddressesByProviderID(providerID string) ([]v1.NodeAddress, error) {
|
||||
// In AWS, we're using the instanceID as the providerID.
|
||||
instanceID := providerID
|
||||
instanceID, error := instanceIDFromProviderID(providerID)
|
||||
|
||||
if error != nil {
|
||||
return nil, error
|
||||
}
|
||||
|
||||
addresses, error := c.describeAddressesByInstanceID(instanceID)
|
||||
|
||||
@ -1111,8 +1114,11 @@ func (c *Cloud) InstanceID(nodeName types.NodeName) (string, error) {
|
||||
// This method will not be called from the node that is requesting this ID. i.e. metadata service
|
||||
// and other local methods cannot be used here
|
||||
func (c *Cloud) InstanceTypeByProviderID(providerID string) (string, error) {
|
||||
// In AWS, we're using the instanceID as the providerID.
|
||||
instanceID := providerID
|
||||
instanceID, error := instanceIDFromProviderID(providerID)
|
||||
|
||||
if error != nil {
|
||||
return "", error
|
||||
}
|
||||
|
||||
instance, error := c.describeInstanceByInstanceID(instanceID)
|
||||
|
||||
@ -3573,6 +3579,17 @@ func convertAwsAddress(address *ec2.Address) ([]v1.NodeAddress, error) {
|
||||
return nodeAddresses, nil
|
||||
}
|
||||
|
||||
var providerIDRegexp = regexp.MustCompile(`^aws://([^/]+)$`)
|
||||
|
||||
func instanceIDFromProviderID(providerID string) (instanceID string, err error) {
|
||||
matches := providerIDRegexp.FindStringSubmatch(providerID)
|
||||
if len(matches) != 1 {
|
||||
return "", fmt.Errorf("ProviderID \"%s\" didn't match expected format \"aws://InstanceID\"", providerID)
|
||||
}
|
||||
|
||||
return matches[1], nil
|
||||
}
|
||||
|
||||
func setNodeDisk(
|
||||
nodeDiskMap map[types.NodeName]map[KubernetesVolumeID]bool,
|
||||
volumeID KubernetesVolumeID,
|
||||
|
Loading…
Reference in New Issue
Block a user