Documentation ¶
Index ¶
- Constants
- func BuildTencentCloudProvider(tencentcloudManager TencentcloudManager, ...) (cloudprovider.CloudProvider, error)
- func BuildTencentcloud(opts config.AutoscalingOptions, do cloudprovider.NodeGroupDiscoveryOptions, ...) cloudprovider.CloudProvider
- type Asg
- type CloudConfig
- type CloudService
- type CloudServiceImpl
- func (ts *CloudServiceImpl) DeleteInstances(asg Asg, instances []string) error
- func (ts *CloudServiceImpl) FetchAsgInstances(asgRef TcRef) ([]cloudprovider.Instance, error)
- func (ts *CloudServiceImpl) GetAsgRefByInstanceRef(instanceRef TcRef) (*TcRef, error)
- func (ts *CloudServiceImpl) GetAutoScalingGroup(asgRef TcRef) (*as.AutoScalingGroup, error)
- func (ts *CloudServiceImpl) GetAutoScalingGroups(asgIds []string) ([]as.AutoScalingGroup, error)
- func (ts *CloudServiceImpl) GetAutoScalingInstances(asgRef TcRef) ([]*as.Instance, error)
- func (ts *CloudServiceImpl) GetAutoscalingConfigs(ascs []string) ([]as.LaunchConfiguration, error)
- func (ts *CloudServiceImpl) GetInstanceInfoByType(instanceType string) (*InstanceInfo, error)
- func (ts *CloudServiceImpl) GetTencentcloudInstanceRef(instance *as.Instance) (*TcRef, error)
- func (ts *CloudServiceImpl) GetZoneBySubnetID(subnetID string) (string, error)
- func (ts *CloudServiceImpl) GetZoneInfo(zone string) (*cvm.ZoneInfo, error)
- func (ts *CloudServiceImpl) ResizeAsg(ref TcRef, size uint64) error
- type InstanceInfo
- type InstanceTemplate
- type NetworkExtendedResources
- type SubnetInfo
- type TcRef
- type TencentcloudCache
- func (tc *TencentcloudCache) FindForInstance(instanceRef TcRef) (Asg, error)
- func (tc *TencentcloudCache) GetAsgInstanceTemplate(ref TcRef) (*InstanceTemplate, bool)
- func (tc *TencentcloudCache) GetAsgTargetSize(ref TcRef) (int64, bool)
- func (tc *TencentcloudCache) GetAsgs() []Asg
- func (tc *TencentcloudCache) GetInstanceType(ref TcRef) string
- func (tc *TencentcloudCache) GetResourceLimiter() (*cloudprovider.ResourceLimiter, error)
- func (tc *TencentcloudCache) InvalidateAllAsgTargetSizes()
- func (tc *TencentcloudCache) InvalidateAsgTargetSize(ref TcRef)
- func (tc *TencentcloudCache) RegenerateAutoScalingGroupCache() error
- func (tc *TencentcloudCache) RegenerateInstanceCacheForAsg(asgRef TcRef) error
- func (tc *TencentcloudCache) RegenerateInstancesCache() error
- func (tc *TencentcloudCache) RegisterAsg(newAsg Asg) bool
- func (tc *TencentcloudCache) SetAsgInstanceTemplate(ref TcRef, instanceTemplate *InstanceTemplate)
- func (tc *TencentcloudCache) SetAsgTargetSize(ref TcRef, size int64)
- func (tc *TencentcloudCache) SetResourceLimiter(resourceLimiter *cloudprovider.ResourceLimiter)
- func (tc *TencentcloudCache) UnregisterAsg(toBeRemoved Asg) bool
- type TencentcloudManager
Constants ¶
const ( // ProviderName is the cloud provider name for Tencentcloud ProviderName = "tencentcloud" // GPULabel is the label added to nodes with GPU resource. GPULabel = "cloud.tencent.com/tke-accelerator" )
const ( ASHttpEndpoint = "as.tencentcloudapi.com" VPCHttpEndpoint = "vpc.tencentcloudapi.com" CVMHttpEndpoint = "cvm.tencentcloudapi.com" )
Tencent Cloud Service Http Endpoint
const LabelAutoScalingGroupID = "cloud.tencent.com/auto-scaling-group-id"
LabelAutoScalingGroupID represents the label of AutoScalingGroup
Variables ¶
This section is empty.
Functions ¶
func BuildTencentCloudProvider ¶
func BuildTencentCloudProvider(tencentcloudManager TencentcloudManager, discoveryOpts cloudprovider.NodeGroupDiscoveryOptions, resourceLimiter *cloudprovider.ResourceLimiter) (cloudprovider.CloudProvider, error)
BuildTencentCloudProvider builds CloudProvider implementation for Tencentcloud.
func BuildTencentcloud ¶
func BuildTencentcloud(opts config.AutoscalingOptions, do cloudprovider.NodeGroupDiscoveryOptions, rl *cloudprovider.ResourceLimiter) cloudprovider.CloudProvider
BuildTencentcloud returns tencentcloud provider
Types ¶
type Asg ¶
type Asg interface { cloudprovider.NodeGroup TencentcloudRef() TcRef GetScalingType() string SetScalingType(string) }
Asg implements NodeGroup interface.
type CloudConfig ¶
type CloudConfig struct {
Region string `json:"region"`
}
CloudConfig represent tencentcloud configuration
type CloudService ¶
type CloudService interface { // FetchAsgInstances returns instances of the specified ASG. FetchAsgInstances(TcRef) ([]cloudprovider.Instance, error) // DeleteInstances remove instances of specified ASG. DeleteInstances(Asg, []string) error // GetAsgRefByInstanceRef returns asgRef according to instanceRef GetAsgRefByInstanceRef(TcRef) (*TcRef, error) // GetAutoScalingGroups queries and returns a set of ASG. GetAutoScalingGroups([]string) ([]as.AutoScalingGroup, error) // GetAutoscalingConfigs queries and returns a set of ASG launchconfiguration. GetAutoscalingConfigs([]string) ([]as.LaunchConfiguration, error) // GetAutoScalingGroups queries and returns a set of ASG. GetAutoScalingGroup(TcRef) (*as.AutoScalingGroup, error) // ResizeAsg set the target size of ASG. ResizeAsg(TcRef, uint64) error // GetAutoScalingInstances returns instances of specific ASG. GetAutoScalingInstances(TcRef) ([]*as.Instance, error) // GetTencentcloudInstanceRef returns a Tencentcloud ref. GetTencentcloudInstanceRef(*as.Instance) (*TcRef, error) // GetInstanceInfoByType queries the number of CPU, memory, and GPU resources of the model configured for generating template GetInstanceInfoByType(string) (*InstanceInfo, error) // GetZoneBySubnetID return zone by subnetID. GetZoneBySubnetID(string) (string, error) // GetZoneInfo invokes cvm.DescribeZones to query zone information. GetZoneInfo(string) (*cvm.ZoneInfo, error) }
CloudService is used for communicating with Tencentcloud API.
func NewCloudService ¶
func NewCloudService(cvmClient, vpcClient, asClient client.Client) CloudService
NewCloudService creates an instance of caching CloudServiceImpl
type CloudServiceImpl ¶
type CloudServiceImpl struct {
// contains filtered or unexported fields
}
CloudServiceImpl provides several utility methods over the auto-scaling cloudService provided by Tencentcloud SDK
func (*CloudServiceImpl) DeleteInstances ¶
func (ts *CloudServiceImpl) DeleteInstances(asg Asg, instances []string) error
DeleteInstances remove instances of specified ASG.
func (*CloudServiceImpl) FetchAsgInstances ¶
func (ts *CloudServiceImpl) FetchAsgInstances(asgRef TcRef) ([]cloudprovider.Instance, error)
FetchAsgInstances returns instances of the specified ASG.
func (*CloudServiceImpl) GetAsgRefByInstanceRef ¶
func (ts *CloudServiceImpl) GetAsgRefByInstanceRef(instanceRef TcRef) (*TcRef, error)
GetAsgRefByInstanceRef returns asgRef according to instanceRef
func (*CloudServiceImpl) GetAutoScalingGroup ¶
func (ts *CloudServiceImpl) GetAutoScalingGroup(asgRef TcRef) (*as.AutoScalingGroup, error)
GetAutoScalingGroup returns the specific ASG.
func (*CloudServiceImpl) GetAutoScalingGroups ¶
func (ts *CloudServiceImpl) GetAutoScalingGroups(asgIds []string) ([]as.AutoScalingGroup, error)
GetAutoScalingGroups queries and returns a set of ASG.
func (*CloudServiceImpl) GetAutoScalingInstances ¶
func (ts *CloudServiceImpl) GetAutoScalingInstances(asgRef TcRef) ([]*as.Instance, error)
GetAutoScalingInstances returns instances of specific ASG.
func (*CloudServiceImpl) GetAutoscalingConfigs ¶
func (ts *CloudServiceImpl) GetAutoscalingConfigs(ascs []string) ([]as.LaunchConfiguration, error)
GetAutoscalingConfigs queries and returns a set of ASG launchconfiguration.
func (*CloudServiceImpl) GetInstanceInfoByType ¶
func (ts *CloudServiceImpl) GetInstanceInfoByType(instanceType string) (*InstanceInfo, error)
GetInstanceInfoByType queries the number of CPU, memory, and GPU resources of the model configured for generating template
func (*CloudServiceImpl) GetTencentcloudInstanceRef ¶
func (ts *CloudServiceImpl) GetTencentcloudInstanceRef(instance *as.Instance) (*TcRef, error)
GetTencentcloudInstanceRef returns a Tencentcloud ref.
func (*CloudServiceImpl) GetZoneBySubnetID ¶
func (ts *CloudServiceImpl) GetZoneBySubnetID(subnetID string) (string, error)
GetZoneBySubnetID 查询子网的所属可用区
func (*CloudServiceImpl) GetZoneInfo ¶
func (ts *CloudServiceImpl) GetZoneInfo(zone string) (*cvm.ZoneInfo, error)
GetZoneInfo invokes cvm.DescribeZones to query zone information. zoneInfo will be cache.
type InstanceInfo ¶
type InstanceInfo struct { CPU int64 Memory int64 GPU int64 InstanceFamily string InstanceType string }
InstanceInfo represents CVM's detail
type InstanceTemplate ¶
type InstanceTemplate struct { InstanceType string Region string Zone string Cpu int64 Mem int64 Gpu int64 Tags []*as.Tag }
InstanceTemplate represents CVM template
type NetworkExtendedResources ¶
NetworkExtendedResources represents network extended resources
type SubnetInfo ¶
SubnetInfo represents subnet's detail
type TcRef ¶
TcRef contains a reference to some entity in Tencentcloud/TKE world.
func TcRefFromProviderID ¶
TcRefFromProviderID creates InstanceConfig object from provider id which must be in format: qcloud:///100003/ins-3ven36lk
func (TcRef) ToProviderID ¶
ToProviderID converts tcRef to string in format used as ProviderId in Node object.
type TencentcloudCache ¶
type TencentcloudCache struct {
// contains filtered or unexported fields
}
TencentcloudCache is used for caching cluster resources state.
It is needed to: - keep track of autoscaled ASGs in the cluster, - keep track of instances and which ASG they belong to, - limit repetitive Tencentcloud API calls.
Cached resources: 1) ASG configuration, 2) instance->ASG mapping, 3) resource limits (self-imposed quotas), 4) instance types.
How it works: - asgs (1), resource limits (3) and machine types (4) are only stored in this cache, not updated by it. - instanceRefToAsgRef (2) is based on registered asgs (1). For each asg, its instances are fetched from Tencentcloud API using cloudService. - instanceRefToAsgRef (2) is NOT updated automatically when asgs field (1) is updated. Calling RegenerateInstancesCache is required to sync it with registered asgs.
func NewTencentcloudCache ¶
func NewTencentcloudCache(service CloudService) *TencentcloudCache
NewTencentcloudCache create a empty TencentcloudCache
func (*TencentcloudCache) FindForInstance ¶
func (tc *TencentcloudCache) FindForInstance(instanceRef TcRef) (Asg, error)
FindForInstance returns Asg of the given Instance
func (*TencentcloudCache) GetAsgInstanceTemplate ¶
func (tc *TencentcloudCache) GetAsgInstanceTemplate(ref TcRef) (*InstanceTemplate, bool)
GetAsgInstanceTemplate returns the cached InstanceTemplate for a Asg TcRef
func (*TencentcloudCache) GetAsgTargetSize ¶
func (tc *TencentcloudCache) GetAsgTargetSize(ref TcRef) (int64, bool)
GetAsgTargetSize returns the cached targetSize for a TencentcloudRef
func (*TencentcloudCache) GetAsgs ¶
func (tc *TencentcloudCache) GetAsgs() []Asg
GetAsgs returns a copy of asgs list.
func (*TencentcloudCache) GetInstanceType ¶
func (tc *TencentcloudCache) GetInstanceType(ref TcRef) string
GetInstanceType returns asg instanceType
func (*TencentcloudCache) GetResourceLimiter ¶
func (tc *TencentcloudCache) GetResourceLimiter() (*cloudprovider.ResourceLimiter, error)
GetResourceLimiter returns resource limiter.
func (*TencentcloudCache) InvalidateAllAsgTargetSizes ¶
func (tc *TencentcloudCache) InvalidateAllAsgTargetSizes()
InvalidateAllAsgTargetSizes clears the target size cache
func (*TencentcloudCache) InvalidateAsgTargetSize ¶
func (tc *TencentcloudCache) InvalidateAsgTargetSize(ref TcRef)
InvalidateAsgTargetSize clears the target size cache
func (*TencentcloudCache) RegenerateAutoScalingGroupCache ¶
func (tc *TencentcloudCache) RegenerateAutoScalingGroupCache() error
RegenerateAutoScalingGroupCache add some tencentcloud asg property
func (*TencentcloudCache) RegenerateInstanceCacheForAsg ¶
func (tc *TencentcloudCache) RegenerateInstanceCacheForAsg(asgRef TcRef) error
RegenerateInstanceCacheForAsg triggers instances cache regeneration for single ASG under lock.
func (*TencentcloudCache) RegenerateInstancesCache ¶
func (tc *TencentcloudCache) RegenerateInstancesCache() error
RegenerateInstancesCache triggers instances cache regeneration under lock.
func (*TencentcloudCache) RegisterAsg ¶
func (tc *TencentcloudCache) RegisterAsg(newAsg Asg) bool
RegisterAsg registers asg in Tencentcloud Manager.
func (*TencentcloudCache) SetAsgInstanceTemplate ¶
func (tc *TencentcloudCache) SetAsgInstanceTemplate(ref TcRef, instanceTemplate *InstanceTemplate)
SetAsgInstanceTemplate sets InstanceTemplate for a Asg TcRef
func (*TencentcloudCache) SetAsgTargetSize ¶
func (tc *TencentcloudCache) SetAsgTargetSize(ref TcRef, size int64)
SetAsgTargetSize sets targetSize for a TencentcloudRef
func (*TencentcloudCache) SetResourceLimiter ¶
func (tc *TencentcloudCache) SetResourceLimiter(resourceLimiter *cloudprovider.ResourceLimiter)
SetResourceLimiter sets resource limiter.
func (*TencentcloudCache) UnregisterAsg ¶
func (tc *TencentcloudCache) UnregisterAsg(toBeRemoved Asg) bool
UnregisterAsg returns true if the node group has been removed, and false if it was already missing from cache.
type TencentcloudManager ¶
type TencentcloudManager interface { // Refresh triggers refresh of cached resources. Refresh() error // Cleanup cleans up open resources before the cloud provider is destroyed, i.e. go routines etc. Cleanup() error RegisterAsg(asg Asg) // GetAsgs returns list of registered Asgs. GetAsgs() []Asg // GetAsgNodes returns Asg nodes. GetAsgNodes(Asg Asg) ([]cloudprovider.Instance, error) // GetAsgForInstance returns Asg to which the given instance belongs. GetAsgForInstance(instance TcRef) (Asg, error) // GetAsgTemplateNode returns a template node for Asg. GetAsgTemplateNode(Asg Asg) (*apiv1.Node, error) // GetResourceLimiter returns resource limiter. GetResourceLimiter() (*cloudprovider.ResourceLimiter, error) // GetAsgSize gets Asg size. GetAsgSize(Asg Asg) (int64, error) // SetAsgSize sets Asg size. SetAsgSize(Asg Asg, size int64) error // DeleteInstances deletes the given instances. All instances must be controlled by the same Asg. DeleteInstances(instances []TcRef) error }
TencentcloudManager is handles tencentcloud communication and data caching.
func CreateTencentcloudManager ¶
func CreateTencentcloudManager(discoveryOpts cloudprovider.NodeGroupDiscoveryOptions, regional bool) (TencentcloudManager, error)
CreateTencentcloudManager constructs tencentcloudManager object.