mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 11:21:47 +00:00
Merge pull request #92367 from gongguan/instancev2
define and implement cloud InstanceV2
This commit is contained in:
commit
30dbfbec84
@ -645,6 +645,10 @@ func (testcase *testcase) Instances() (cloudprovider.Instances, bool) {
|
||||
return &instances{testcase.instanceID}, true
|
||||
}
|
||||
|
||||
func (testcase *testcase) InstancesV2() (cloudprovider.InstancesV2, bool) {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
func (testcase *testcase) DisksAreAttached(instanceID string, volumeIDs []string) (map[string]bool, error) {
|
||||
expected := &testcase.disksAreAttached
|
||||
|
||||
|
@ -49,6 +49,9 @@ type Interface interface {
|
||||
LoadBalancer() (LoadBalancer, bool)
|
||||
// Instances returns an instances interface. Also returns true if the interface is supported, false otherwise.
|
||||
Instances() (Instances, bool)
|
||||
// InstancesV2 is an implementation for instances only used by cloud node-controller now.
|
||||
// Also returns true if the interface is supported, false otherwise.
|
||||
InstancesV2() (InstancesV2, bool)
|
||||
// Zones returns a zones interface. Also returns true if the interface is supported, false otherwise.
|
||||
Zones() (Zones, bool)
|
||||
// Clusters returns a clusters interface. Also returns true if the interface is supported, false otherwise.
|
||||
@ -186,6 +189,17 @@ type Instances interface {
|
||||
InstanceShutdownByProviderID(ctx context.Context, providerID string) (bool, error)
|
||||
}
|
||||
|
||||
// InstancesV2 is an abstract, pluggable interface for sets of instances.
|
||||
// Unlike Instances, it is only used by cloud node-controller now.
|
||||
type InstancesV2 interface {
|
||||
// InstanceExistsByProviderID returns true if the instance for the given provider exists.
|
||||
InstanceExistsByProviderID(ctx context.Context, providerID string) (bool, error)
|
||||
// InstanceShutdownByProviderID returns true if the instance is shutdown in cloudprovider.
|
||||
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.
|
||||
type Route struct {
|
||||
// Name is the name of the routing rule in the cloud-provider.
|
||||
|
@ -59,6 +59,7 @@ type Cloud struct {
|
||||
Exists bool
|
||||
Err error
|
||||
|
||||
EnableInstancesV2 bool
|
||||
ExistsByProviderID bool
|
||||
ErrByProviderID error
|
||||
NodeShutdown bool
|
||||
@ -152,6 +153,16 @@ func (f *Cloud) Instances() (cloudprovider.Instances, bool) {
|
||||
return f, true
|
||||
}
|
||||
|
||||
// InstancesV2 returns a fake implementation of InstancesV2.
|
||||
//
|
||||
// Actually it just returns f itself.
|
||||
func (f *Cloud) InstancesV2() (cloudprovider.InstancesV2, bool) {
|
||||
if f.EnableInstancesV2 {
|
||||
return f, true
|
||||
}
|
||||
return nil, false
|
||||
}
|
||||
|
||||
// Zones returns a zones interface. Also returns true if the interface is supported, false otherwise.
|
||||
func (f *Cloud) Zones() (cloudprovider.Zones, bool) {
|
||||
return f, true
|
||||
|
@ -1394,6 +1394,11 @@ func (c *Cloud) Instances() (cloudprovider.Instances, bool) {
|
||||
return c, true
|
||||
}
|
||||
|
||||
// InstancesV2 returns an implementation of InstancesV2 for Amazon Web Services.
|
||||
func (c *Cloud) InstancesV2() (cloudprovider.InstancesV2, bool) {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
// Zones returns an implementation of Zones for Amazon Web Services.
|
||||
func (c *Cloud) Zones() (cloudprovider.Zones, bool) {
|
||||
return c, true
|
||||
|
@ -664,6 +664,11 @@ func (az *Cloud) Instances() (cloudprovider.Instances, bool) {
|
||||
return az, true
|
||||
}
|
||||
|
||||
// InstancesV2 returns an instancesV2 interface. Also returns true if the interface is supported, false otherwise.
|
||||
func (az *Cloud) InstancesV2() (cloudprovider.InstancesV2, bool) {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
// Zones returns a zones interface. Also returns true if the interface is supported, false otherwise.
|
||||
func (az *Cloud) Zones() (cloudprovider.Zones, bool) {
|
||||
return az, true
|
||||
|
@ -659,6 +659,11 @@ func (g *Cloud) Instances() (cloudprovider.Instances, bool) {
|
||||
return g, true
|
||||
}
|
||||
|
||||
// InstancesV2 returns an implementation of InstancesV2 for Google Compute Engine.
|
||||
func (g *Cloud) InstancesV2() (cloudprovider.InstancesV2, bool) {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
// Zones returns an implementation of Zones for Google Compute Engine.
|
||||
func (g *Cloud) Zones() (cloudprovider.Zones, bool) {
|
||||
return g, true
|
||||
|
@ -62,6 +62,11 @@ func (os *OpenStack) Instances() (cloudprovider.Instances, bool) {
|
||||
}, true
|
||||
}
|
||||
|
||||
// InstancesV2 returns an implementation of InstancesV2 for OpenStack.
|
||||
func (os *OpenStack) InstancesV2() (cloudprovider.InstancesV2, bool) {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
// CurrentNodeName implements Instances.CurrentNodeName
|
||||
// Note this is *not* necessarily the same as hostname.
|
||||
func (i *Instances) CurrentNodeName(ctx context.Context, hostname string) (types.NodeName, error) {
|
||||
|
@ -560,6 +560,11 @@ func (vs *VSphere) Instances() (cloudprovider.Instances, bool) {
|
||||
return vs, true
|
||||
}
|
||||
|
||||
// InstancesV2 returns an implementation of InstancesV2 for vSphere.
|
||||
func (vs *VSphere) InstancesV2() (cloudprovider.InstancesV2, bool) {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
func getLocalIP() ([]v1.NodeAddress, error) {
|
||||
// hashtable with VMware-allocated OUIs for MAC filtering
|
||||
// List of official OUIs: http://standards-oui.ieee.org/oui.txt
|
||||
|
Loading…
Reference in New Issue
Block a user