Documentation
¶
Index ¶
- Variables
- func ConvertToVirtualMachineIdentity(nodeIdentities []string) *armcompute.VirtualMachineIdentity
- func CreateVirtualMachine(ctx context.Context, client VirtualMachinesAPI, rg, vmName string, ...) (*armcompute.VirtualMachine, error)
- func ErrorCodeForMetrics(err error) string
- func GenerateResourceName(nodeClaimName string) string
- func GetCapacityTypeFromVM(vm *armcompute.VirtualMachine) string
- func GetManagedExtensionNames(provisionMode string) []string
- func GetNICListQueryBuilder(rg string) *kql.Builder
- func GetVMListQueryBuilder(rg string) *kql.Builder
- func IsAKSMachineOrMachinesPoolNotFound(err error) bool
- func NewQueryRequest(subscriptionID *string, query string) *arg.QueryRequest
- func UpdateVirtualMachine(ctx context.Context, client VirtualMachinesAPI, rg, vmName string, ...) error
- type AKSAgentPoolsAPI
- type AKSMachinesAPI
- type AZClient
- type AzureResourceGraphAPI
- type DefaultVMProvider
- func (p *DefaultVMProvider) BeginCreate(ctx context.Context, nodeClass *v1beta1.AKSNodeClass, ...) (*VirtualMachinePromise, error)
- func (p *DefaultVMProvider) Delete(ctx context.Context, resourceName string) error
- func (p *DefaultVMProvider) DeleteNic(ctx context.Context, nicName string) error
- func (p *DefaultVMProvider) Get(ctx context.Context, vmName string) (*armcompute.VirtualMachine, error)
- func (p *DefaultVMProvider) GetNic(ctx context.Context, rg, nicName string) (*armnetwork.Interface, error)
- func (p *DefaultVMProvider) List(ctx context.Context) ([]*armcompute.VirtualMachine, error)
- func (p *DefaultVMProvider) ListNics(ctx context.Context) ([]*armnetwork.Interface, error)
- func (p *DefaultVMProvider) Update(ctx context.Context, vmName string, update armcompute.VirtualMachineUpdate) error
- type NetworkInterfacesAPI
- type Promise
- type Resource
- type SubnetsAPI
- type VMProvider
- type VirtualMachineExtensionsAPI
- type VirtualMachinePromise
- type VirtualMachinesAPI
Constants ¶
This section is empty.
Variables ¶
var ( // VMCreateStartMetric tracks when VM creation starts. // // STABILITY: ALPHA - This metric may change or be removed without notice. VMCreateStartMetric = prometheus.NewCounterVec( prometheus.CounterOpts{ Namespace: metrics.Namespace, Subsystem: instanceSubsystem, Name: "vm_create_start_total", Help: "Total number of VM creation operations started.", }, []string{metrics.ImageLabel, metrics.SizeLabel, metrics.ZoneLabel, metrics.CapacityTypeLabel, metrics.NodePoolLabel}, ) // VMCreateFailureMetric tracks VM creation failures, regardless of phase. // // STABILITY: ALPHA - This metric may change or be removed without notice. VMCreateFailureMetric = prometheus.NewCounterVec( prometheus.CounterOpts{ Namespace: metrics.Namespace, Subsystem: instanceSubsystem, Name: "vm_create_failure_total", Help: "Total number of VM creation failures.", }, []string{metrics.ImageLabel, metrics.SizeLabel, metrics.ZoneLabel, metrics.CapacityTypeLabel, metrics.NodePoolLabel, metrics.PhaseLabel, metrics.ErrorCodeLabel}, ) )
We don't need to add disk specification since they are statically defined and can be traced with provided labels.
var ( KarpCapacityTypeToVMPriority = map[string]armcompute.VirtualMachinePriorityTypes{ karpv1.CapacityTypeSpot: armcompute.VirtualMachinePriorityTypesSpot, karpv1.CapacityTypeOnDemand: armcompute.VirtualMachinePriorityTypesRegular, } VMPriorityToKarpCapacityType = map[armcompute.VirtualMachinePriorityTypes]string{ armcompute.VirtualMachinePriorityTypesSpot: karpv1.CapacityTypeSpot, armcompute.VirtualMachinePriorityTypesRegular: karpv1.CapacityTypeOnDemand, } )
Functions ¶
func ConvertToVirtualMachineIdentity ¶
func ConvertToVirtualMachineIdentity(nodeIdentities []string) *armcompute.VirtualMachineIdentity
func CreateVirtualMachine ¶
func CreateVirtualMachine(ctx context.Context, client VirtualMachinesAPI, rg, vmName string, vm armcompute.VirtualMachine) (*armcompute.VirtualMachine, error)
func ErrorCodeForMetrics ¶ added in v1.6.6
ErrorCodeForMetrics extracts a stable Azure error code for metric labeling when possible.
func GenerateResourceName ¶
E.g., aks-default-2jf98
func GetCapacityTypeFromVM ¶ added in v1.6.6
func GetCapacityTypeFromVM(vm *armcompute.VirtualMachine) string
func GetManagedExtensionNames ¶ added in v1.6.2
GetManagedExtensionNames gets the names of the VM extensions managed by Karpenter. This is a set of 1 or 2 extensions (depending on provisionMode): aksIdentifyingExtension and (sometimes) cse.
func GetNICListQueryBuilder ¶ added in v0.6.2
GetNICListQueryBuilder returns a KQL query builder for listing NICs with nodepool tags
func GetVMListQueryBuilder ¶ added in v0.6.2
GetVMListQueryBuilder returns a KQL query builder for listing VMs with nodepool tags
func IsAKSMachineOrMachinesPoolNotFound ¶ added in v1.6.8
func NewQueryRequest ¶
func NewQueryRequest(subscriptionID *string, query string) *arg.QueryRequest
func UpdateVirtualMachine ¶
func UpdateVirtualMachine(ctx context.Context, client VirtualMachinesAPI, rg, vmName string, updates armcompute.VirtualMachineUpdate) error
Types ¶
type AKSAgentPoolsAPI ¶ added in v1.6.8
type AKSAgentPoolsAPI interface {
Get(ctx context.Context, resourceGroupName string, resourceName string, agentPoolName string, options *armcontainerservice.AgentPoolsClientGetOptions) (armcontainerservice.AgentPoolsClientGetResponse, error)
BeginDeleteMachines(ctx context.Context, resourceGroupName string, resourceName string, agentPoolName string, aksMachines armcontainerservice.AgentPoolDeleteMachinesParameter, options *armcontainerservice.AgentPoolsClientBeginDeleteMachinesOptions) (*runtime.Poller[armcontainerservice.AgentPoolsClientDeleteMachinesResponse], error)
}
func NewNoAKSAgentPoolsClient ¶ added in v1.6.8
func NewNoAKSAgentPoolsClient() AKSAgentPoolsAPI
NewNoAKSAgentPoolsClient creates a new dry AKS agent pools client, attempting to create real client internally
type AKSMachinesAPI ¶ added in v1.6.8
type AKSMachinesAPI interface {
BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, agentPoolName string, aksMachineName string, parameters armcontainerservice.Machine, options *armcontainerservice.MachinesClientBeginCreateOrUpdateOptions) (*runtime.Poller[armcontainerservice.MachinesClientCreateOrUpdateResponse], error)
Get(ctx context.Context, resourceGroupName string, resourceName string, agentPoolName string, aksMachineName string, options *armcontainerservice.MachinesClientGetOptions) (armcontainerservice.MachinesClientGetResponse, error)
NewListPager(resourceGroupName string, resourceName string, agentPoolName string, options *armcontainerservice.MachinesClientListOptions) *runtime.Pager[armcontainerservice.MachinesClientListResponse]
}
func NewNoAKSMachinesClient ¶ added in v1.6.8
func NewNoAKSMachinesClient() AKSMachinesAPI
type AZClient ¶
type AZClient struct {
NodeImageVersionsClient imagefamilytypes.NodeImageVersionsAPI
ImageVersionsClient imagefamilytypes.CommunityGalleryImageVersionsAPI
NodeBootstrappingClient imagefamilytypes.NodeBootstrappingAPI
// SKU CLIENT is still using track 1 because skewer does not support the track 2 path. We need to refactor this once skewer supports track 2
SKUClient skewer.ResourceClient
LoadBalancersClient loadbalancer.LoadBalancersAPI
NetworkSecurityGroupsClient networksecuritygroup.API
SubscriptionsClient zone.SubscriptionsAPI
// contains filtered or unexported fields
}
TODO: Move this to another package that more correctly reflects its usage across multiple providers
func NewAZClient ¶
func NewAZClient(ctx context.Context, cfg *auth.Config, env *auth.Environment, cred azcore.TokenCredential) (*AZClient, error)
nolint: gocyclo
func NewAZClientFromAPI ¶
func NewAZClientFromAPI( virtualMachinesClient VirtualMachinesAPI, azureResourceGraphClient AzureResourceGraphAPI, aksMachinesClient AKSMachinesAPI, agentPoolsClient AKSAgentPoolsAPI, virtualMachinesExtensionClient VirtualMachineExtensionsAPI, interfacesClient NetworkInterfacesAPI, subnetsClient SubnetsAPI, loadBalancersClient loadbalancer.LoadBalancersAPI, networkSecurityGroupsClient networksecuritygroup.API, imageVersionsClient imagefamilytypes.CommunityGalleryImageVersionsAPI, nodeImageVersionsClient imagefamilytypes.NodeImageVersionsAPI, nodeBootstrappingClient imagefamilytypes.NodeBootstrappingAPI, skuClient skewer.ResourceClient, subscriptionsClient zone.SubscriptionsAPI, ) *AZClient
func (*AZClient) SubnetsClient ¶ added in v1.6.2
func (c *AZClient) SubnetsClient() SubnetsAPI
type AzureResourceGraphAPI ¶
type AzureResourceGraphAPI interface {
Resources(ctx context.Context, query armresourcegraph.QueryRequest, options *armresourcegraph.ClientResourcesOptions) (armresourcegraph.ClientResourcesResponse, error)
}
type DefaultVMProvider ¶ added in v1.6.6
type DefaultVMProvider struct {
// contains filtered or unexported fields
}
func NewDefaultVMProvider ¶ added in v1.6.6
func NewDefaultVMProvider( azClient *AZClient, instanceTypeProvider instancetype.Provider, launchTemplateProvider *launchtemplate.Provider, loadBalancerProvider *loadbalancer.Provider, networkSecurityGroupProvider *networksecuritygroup.Provider, offeringsCache *cache.UnavailableOfferings, location string, resourceGroup string, subscriptionID string, provisionMode string, diskEncryptionSetID string, ) *DefaultVMProvider
func (*DefaultVMProvider) BeginCreate ¶ added in v1.6.6
func (p *DefaultVMProvider) BeginCreate( ctx context.Context, nodeClass *v1beta1.AKSNodeClass, nodeClaim *karpv1.NodeClaim, instanceTypes []*corecloudprovider.InstanceType, ) (*VirtualMachinePromise, error)
BeginCreate creates an instance given the constraints. instanceTypes should be sorted by priority for spot capacity type. Note that the returned instance may not be finished provisioning yet. Errors that occur on the "sync side" of the VM create, such as quota/capacity, BadRequest due to invalid user input, and similar, will have the error returned here. Errors that occur on the "async side" of the VM create (after the request is accepted, or after polling the VM create and while ) will be returned from the VirtualMachinePromise.Wait() function.
func (*DefaultVMProvider) Delete ¶ added in v1.6.6
func (p *DefaultVMProvider) Delete(ctx context.Context, resourceName string) error
func (*DefaultVMProvider) DeleteNic ¶ added in v1.6.6
func (p *DefaultVMProvider) DeleteNic(ctx context.Context, nicName string) error
func (*DefaultVMProvider) Get ¶ added in v1.6.6
func (p *DefaultVMProvider) Get(ctx context.Context, vmName string) (*armcompute.VirtualMachine, error)
func (*DefaultVMProvider) GetNic ¶ added in v1.6.6
func (p *DefaultVMProvider) GetNic(ctx context.Context, rg, nicName string) (*armnetwork.Interface, error)
func (*DefaultVMProvider) List ¶ added in v1.6.6
func (p *DefaultVMProvider) List(ctx context.Context) ([]*armcompute.VirtualMachine, error)
func (*DefaultVMProvider) ListNics ¶ added in v1.6.6
func (p *DefaultVMProvider) ListNics(ctx context.Context) ([]*armnetwork.Interface, error)
ListNics returns all network interfaces in the resource group that have the nodepool tag
func (*DefaultVMProvider) Update ¶ added in v1.6.6
func (p *DefaultVMProvider) Update(ctx context.Context, vmName string, update armcompute.VirtualMachineUpdate) error
Update updates the VM with the given updates. If Tags are specified, the tags are also updated on the associated network interface and VM extensions. Note that this means that this method can fail if the extensions have not been created yet. It is expected that the caller handles this and retries the update to propagate the tags to the extensions once they're created.
type NetworkInterfacesAPI ¶
type NetworkInterfacesAPI interface {
BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, networkInterfaceName string, parameters armnetwork.Interface, options *armnetwork.InterfacesClientBeginCreateOrUpdateOptions) (*runtime.Poller[armnetwork.InterfacesClientCreateOrUpdateResponse], error)
BeginDelete(ctx context.Context, resourceGroupName string, networkInterfaceName string, options *armnetwork.InterfacesClientBeginDeleteOptions) (*runtime.Poller[armnetwork.InterfacesClientDeleteResponse], error)
Get(ctx context.Context, resourceGroupName string, networkInterfaceName string, options *armnetwork.InterfacesClientGetOptions) (armnetwork.InterfacesClientGetResponse, error)
UpdateTags(ctx context.Context, resourceGroupName string, networkInterfaceName string, tags armnetwork.TagsObject, options *armnetwork.InterfacesClientUpdateTagsOptions) (armnetwork.InterfacesClientUpdateTagsResponse, error)
}
type Promise ¶ added in v1.6.6
type Promise interface {
// Cleanup removes the instance from the cloud provider.
Cleanup(ctx context.Context) error
// Wait blocks until the instance is ready.
Wait() error
// GetInstanceName returns the name of the instance. Recommended to be used for logging only due to generic nature.
GetInstanceName() string
}
Intended for lifecycle handling on the higher abstractions.
type Resource ¶
type Resource = map[string]interface{}
func GetResourceData ¶
func GetResourceData(ctx context.Context, client AzureResourceGraphAPI, req arg.QueryRequest) ([]Resource, error)
Queries Azure Resource Graph using Resources() and returns a list of all pages of data.
type SubnetsAPI ¶ added in v1.6.2
type SubnetsAPI interface {
Get(ctx context.Context, resourceGroupName string, virtualNetworkName string, subnetName string, options *armnetwork.SubnetsClientGetOptions) (armnetwork.SubnetsClientGetResponse, error)
}
type VMProvider ¶ added in v1.6.6
type VMProvider interface {
BeginCreate(context.Context, *v1beta1.AKSNodeClass, *karpv1.NodeClaim, []*corecloudprovider.InstanceType) (*VirtualMachinePromise, error)
Get(context.Context, string) (*armcompute.VirtualMachine, error)
List(context.Context) ([]*armcompute.VirtualMachine, error)
Delete(context.Context, string) error
Update(context.Context, string, armcompute.VirtualMachineUpdate) error
GetNic(context.Context, string, string) (*armnetwork.Interface, error)
DeleteNic(context.Context, string) error
ListNics(context.Context) ([]*armnetwork.Interface, error)
}
type VirtualMachineExtensionsAPI ¶
type VirtualMachineExtensionsAPI interface {
BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, vmName string, vmExtensionName string, extensionParameters armcompute.VirtualMachineExtension, options *armcompute.VirtualMachineExtensionsClientBeginCreateOrUpdateOptions) (*runtime.Poller[armcompute.VirtualMachineExtensionsClientCreateOrUpdateResponse], error)
BeginUpdate(ctx context.Context, resourceGroupName string, vmName string, vmExtensionName string, extensionParameters armcompute.VirtualMachineExtensionUpdate, options *armcompute.VirtualMachineExtensionsClientBeginUpdateOptions) (*runtime.Poller[armcompute.VirtualMachineExtensionsClientUpdateResponse], error)
}
type VirtualMachinePromise ¶ added in v1.4.0
type VirtualMachinePromise struct {
VM *armcompute.VirtualMachine
WaitFunc func() error
// contains filtered or unexported fields
}
func (*VirtualMachinePromise) Cleanup ¶ added in v1.6.6
func (p *VirtualMachinePromise) Cleanup(ctx context.Context) error
func (*VirtualMachinePromise) GetInstanceName ¶ added in v1.6.6
func (p *VirtualMachinePromise) GetInstanceName() string
func (*VirtualMachinePromise) Wait ¶ added in v1.4.0
func (p *VirtualMachinePromise) Wait() error
type VirtualMachinesAPI ¶
type VirtualMachinesAPI interface {
BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, vmName string, parameters armcompute.VirtualMachine, options *armcompute.VirtualMachinesClientBeginCreateOrUpdateOptions) (*runtime.Poller[armcompute.VirtualMachinesClientCreateOrUpdateResponse], error)
Get(ctx context.Context, resourceGroupName string, vmName string, options *armcompute.VirtualMachinesClientGetOptions) (armcompute.VirtualMachinesClientGetResponse, error)
BeginUpdate(ctx context.Context, resourceGroupName string, vmName string, parameters armcompute.VirtualMachineUpdate, options *armcompute.VirtualMachinesClientBeginUpdateOptions) (*runtime.Poller[armcompute.VirtualMachinesClientUpdateResponse], error)
BeginDelete(ctx context.Context, resourceGroupName string, vmName string, options *armcompute.VirtualMachinesClientBeginDeleteOptions) (*runtime.Poller[armcompute.VirtualMachinesClientDeleteResponse], error)
}