mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 06:27:05 +00:00
define cloud-provider InstanceMetadata and InstanceMetadataByProviderID function
This commit is contained in:
parent
9d3406c27b
commit
260a9005a0
@ -734,6 +734,10 @@ func (instances *instances) InstanceShutdownByProviderID(ctx context.Context, pr
|
|||||||
return false, errors.New("unimplemented")
|
return false, errors.New("unimplemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (instances *instances) InstanceMetadataByProviderID(ctx context.Context, providerID string) (*cloudprovider.InstanceMetadata, error) {
|
||||||
|
return nil, errors.New("unimplemented")
|
||||||
|
}
|
||||||
|
|
||||||
func (instances *instances) List(filter string) ([]types.NodeName, error) {
|
func (instances *instances) List(filter string) ([]types.NodeName, error) {
|
||||||
return []types.NodeName{}, errors.New("Not implemented")
|
return []types.NodeName{}, errors.New("Not implemented")
|
||||||
}
|
}
|
||||||
|
@ -163,6 +163,7 @@ type Instances interface {
|
|||||||
// ProviderID is a unique identifier of the node. This will not be called
|
// ProviderID is a unique identifier of the node. This will not be called
|
||||||
// from the node whose nodeaddresses are being queried. i.e. local metadata
|
// from the node whose nodeaddresses are being queried. i.e. local metadata
|
||||||
// services cannot be used in this method to obtain nodeaddresses
|
// services cannot be used in this method to obtain nodeaddresses
|
||||||
|
// Deprecated: Remove once all calls are migrated to InstanceMetadataByProviderID
|
||||||
NodeAddressesByProviderID(ctx context.Context, providerID string) ([]v1.NodeAddress, error)
|
NodeAddressesByProviderID(ctx context.Context, providerID string) ([]v1.NodeAddress, error)
|
||||||
// InstanceID returns the cloud provider ID of the node with the specified NodeName.
|
// InstanceID returns the cloud provider ID of the node with the specified NodeName.
|
||||||
// Note that if the instance does not exist, we must return ("", cloudprovider.InstanceNotFound)
|
// Note that if the instance does not exist, we must return ("", cloudprovider.InstanceNotFound)
|
||||||
@ -171,6 +172,7 @@ type Instances interface {
|
|||||||
// InstanceType returns the type of the specified instance.
|
// InstanceType returns the type of the specified instance.
|
||||||
InstanceType(ctx context.Context, name types.NodeName) (string, error)
|
InstanceType(ctx context.Context, name types.NodeName) (string, error)
|
||||||
// InstanceTypeByProviderID returns the type of the specified instance.
|
// InstanceTypeByProviderID returns the type of the specified instance.
|
||||||
|
// Deprecated: Remove once all calls are migrated to InstanceMetadataByProviderID
|
||||||
InstanceTypeByProviderID(ctx context.Context, providerID string) (string, error)
|
InstanceTypeByProviderID(ctx context.Context, providerID string) (string, error)
|
||||||
// AddSSHKeyToAllInstances adds an SSH public key as a legal identity for all instances
|
// AddSSHKeyToAllInstances adds an SSH public key as a legal identity for all instances
|
||||||
// expected format for the key is standard ssh-keygen format: <protocol> <blob>
|
// expected format for the key is standard ssh-keygen format: <protocol> <blob>
|
||||||
@ -181,9 +183,12 @@ type Instances interface {
|
|||||||
// InstanceExistsByProviderID returns true if the instance for the given provider exists.
|
// InstanceExistsByProviderID returns true if the instance for the given provider exists.
|
||||||
// If false is returned with no error, the instance will be immediately deleted by the cloud controller manager.
|
// If false is returned with no error, the instance will be immediately deleted by the cloud controller manager.
|
||||||
// This method should still return true for instances that exist but are stopped/sleeping.
|
// This method should still return true for instances that exist but are stopped/sleeping.
|
||||||
|
// Deprecated: Remove once all calls are migrated to InstanceMetadataByProviderID
|
||||||
InstanceExistsByProviderID(ctx context.Context, providerID string) (bool, error)
|
InstanceExistsByProviderID(ctx context.Context, providerID string) (bool, error)
|
||||||
// InstanceShutdownByProviderID returns true if the instance is shutdown in cloudprovider
|
// InstanceShutdownByProviderID returns true if the instance is shutdown in cloudprovider
|
||||||
InstanceShutdownByProviderID(ctx context.Context, providerID string) (bool, error)
|
InstanceShutdownByProviderID(ctx context.Context, providerID string) (bool, error)
|
||||||
|
// InstanceMetadataByProviderID returns the instance's metadata.
|
||||||
|
InstanceMetadataByProviderID(ctx context.Context, providerID string) (*InstanceMetadata, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Route is a representation of an advanced routing rule.
|
// Route is a representation of an advanced routing rule.
|
||||||
@ -250,3 +255,13 @@ type Zones interface {
|
|||||||
type PVLabeler interface {
|
type PVLabeler interface {
|
||||||
GetLabelsForVolume(ctx context.Context, pv *v1.PersistentVolume) (map[string]string, error)
|
GetLabelsForVolume(ctx context.Context, pv *v1.PersistentVolume) (map[string]string, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// InstanceMetadata contains metadata about the specific instance.
|
||||||
|
type InstanceMetadata struct {
|
||||||
|
// ProviderID is provider's id that instance belongs to.
|
||||||
|
ProviderID string
|
||||||
|
// Type is instance's type.
|
||||||
|
Type string
|
||||||
|
// NodeAddress contains information for the instance's address.
|
||||||
|
NodeAddresses []v1.NodeAddress
|
||||||
|
}
|
||||||
|
@ -292,6 +292,18 @@ func (f *Cloud) InstanceShutdownByProviderID(ctx context.Context, providerID str
|
|||||||
return f.NodeShutdown, f.ErrShutdownByProviderID
|
return f.NodeShutdown, f.ErrShutdownByProviderID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// InstanceMetadataByProviderID returns metadata of the specified instance.
|
||||||
|
func (f *Cloud) InstanceMetadataByProviderID(ctx context.Context, providerID string) (*cloudprovider.InstanceMetadata, error) {
|
||||||
|
f.addCall("instance-metadata-by-provider-id")
|
||||||
|
f.addressesMux.Lock()
|
||||||
|
defer f.addressesMux.Unlock()
|
||||||
|
return &cloudprovider.InstanceMetadata{
|
||||||
|
ProviderID: providerID,
|
||||||
|
Type: f.InstanceTypes[types.NodeName(providerID)],
|
||||||
|
NodeAddresses: f.Addresses,
|
||||||
|
}, f.Err
|
||||||
|
}
|
||||||
|
|
||||||
// List is a test-spy implementation of Instances.List.
|
// List is a test-spy implementation of Instances.List.
|
||||||
// It adds an entry "list" into the internal method call record.
|
// It adds an entry "list" into the internal method call record.
|
||||||
func (f *Cloud) List(filter string) ([]types.NodeName, error) {
|
func (f *Cloud) List(filter string) ([]types.NodeName, error) {
|
||||||
|
@ -1646,6 +1646,11 @@ func (c *Cloud) InstanceShutdownByProviderID(ctx context.Context, providerID str
|
|||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// InstanceMetadataByProviderID returns metadata of the specified instance.
|
||||||
|
func (c *Cloud) InstanceMetadataByProviderID(ctx context.Context, providerID string) (*cloudprovider.InstanceMetadata, error) {
|
||||||
|
return nil, fmt.Errorf("unimplemented")
|
||||||
|
}
|
||||||
|
|
||||||
// InstanceID returns the cloud provider ID of the node with the specified nodeName.
|
// InstanceID returns the cloud provider ID of the node with the specified nodeName.
|
||||||
func (c *Cloud) InstanceID(ctx context.Context, nodeName types.NodeName) (string, error) {
|
func (c *Cloud) InstanceID(ctx context.Context, nodeName types.NodeName) (string, error) {
|
||||||
// In the future it is possible to also return an endpoint as:
|
// In the future it is possible to also return an endpoint as:
|
||||||
|
@ -230,6 +230,11 @@ func (az *Cloud) InstanceShutdownByProviderID(ctx context.Context, providerID st
|
|||||||
return strings.ToLower(powerStatus) == vmPowerStateStopped || strings.ToLower(powerStatus) == vmPowerStateDeallocated, nil
|
return strings.ToLower(powerStatus) == vmPowerStateStopped || strings.ToLower(powerStatus) == vmPowerStateDeallocated, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// InstanceMetadataByProviderID returns metadata of the specified instance.
|
||||||
|
func (az *Cloud) InstanceMetadataByProviderID(ctx context.Context, providerID string) (*cloudprovider.InstanceMetadata, error) {
|
||||||
|
return nil, fmt.Errorf("unimplemented")
|
||||||
|
}
|
||||||
|
|
||||||
func (az *Cloud) isCurrentInstance(name types.NodeName, metadataVMName string) (bool, error) {
|
func (az *Cloud) isCurrentInstance(name types.NodeName, metadataVMName string) (bool, error) {
|
||||||
nodeName := mapNodeNameToVMName(name)
|
nodeName := mapNodeNameToVMName(name)
|
||||||
|
|
||||||
|
@ -161,6 +161,11 @@ func (g *Cloud) InstanceShutdownByProviderID(ctx context.Context, providerID str
|
|||||||
return false, cloudprovider.NotImplemented
|
return false, cloudprovider.NotImplemented
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// InstanceMetadataByProviderID returns metadata of the specified instance.
|
||||||
|
func (g *Cloud) InstanceMetadataByProviderID(ctx context.Context, providerID string) (*cloudprovider.InstanceMetadata, error) {
|
||||||
|
return nil, fmt.Errorf("unimplemented")
|
||||||
|
}
|
||||||
|
|
||||||
// InstanceTypeByProviderID returns the cloudprovider instance type of the node
|
// InstanceTypeByProviderID returns the cloudprovider instance type of the node
|
||||||
// with the specified unique providerID This method will not be called from the
|
// with the specified unique providerID This method will not be called from the
|
||||||
// node that is requesting this ID. i.e. metadata service and other local
|
// node that is requesting this ID. i.e. metadata service and other local
|
||||||
|
@ -152,6 +152,11 @@ func (i *Instances) InstanceShutdownByProviderID(ctx context.Context, providerID
|
|||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// InstanceMetadataByProviderID returns metadata of the specified instance.
|
||||||
|
func (i *Instances) InstanceMetadataByProviderID(ctx context.Context, providerID string) (*cloudprovider.InstanceMetadata, error) {
|
||||||
|
return nil, fmt.Errorf("unimplemented")
|
||||||
|
}
|
||||||
|
|
||||||
// InstanceID returns the kubelet's cloud provider ID.
|
// InstanceID returns the kubelet's cloud provider ID.
|
||||||
func (os *OpenStack) InstanceID() (string, error) {
|
func (os *OpenStack) InstanceID() (string, error) {
|
||||||
if len(os.localInstanceID) == 0 {
|
if len(os.localInstanceID) == 0 {
|
||||||
|
@ -770,6 +770,11 @@ func (vs *VSphere) InstanceShutdownByProviderID(ctx context.Context, providerID
|
|||||||
return !isActive, nil
|
return !isActive, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// InstanceMetadataByProviderID returns metadata of the specified instance.
|
||||||
|
func (vs *VSphere) InstanceMetadataByProviderID(ctx context.Context, providerID string) (*cloudprovider.InstanceMetadata, error) {
|
||||||
|
return nil, fmt.Errorf("unimplemented")
|
||||||
|
}
|
||||||
|
|
||||||
// InstanceID returns the cloud provider ID of the node with the specified Name.
|
// InstanceID returns the cloud provider ID of the node with the specified Name.
|
||||||
func (vs *VSphere) InstanceID(ctx context.Context, nodeName k8stypes.NodeName) (string, error) {
|
func (vs *VSphere) InstanceID(ctx context.Context, nodeName k8stypes.NodeName) (string, error) {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user