instance

package
v1.5.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 29, 2025 License: Apache-2.0, Apache-2.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NodePoolTagKey = strings.ReplaceAll(karpv1.NodePoolLabelKey, "/", "_")

	CapacityTypeToPriority = map[string]string{
		karpv1.CapacityTypeSpot:     string(armcompute.VirtualMachinePriorityTypesSpot),
		karpv1.CapacityTypeOnDemand: string(armcompute.VirtualMachinePriorityTypesRegular),
	}
	PriorityToCapacityType = map[string]string{
		string(armcompute.VirtualMachinePriorityTypesSpot):    karpv1.CapacityTypeSpot,
		string(armcompute.VirtualMachinePriorityTypesRegular): karpv1.CapacityTypeOnDemand,
	}

	SubscriptionQuotaReachedReason              = "SubscriptionQuotaReached"
	AllocationFailureReason                     = "AllocationFailure"
	ZonalAllocationFailureReason                = "ZonalAllocationFailure"
	OverconstrainedZonalAllocationFailureReason = "OverconstrainedZonalAllocationFailure"
	OverconstrainedAllocationFailureReason      = "OverconstrainedAllocationFailure"
	SKUNotAvailableReason                       = "SKUNotAvailable"

	SubscriptionQuotaReachedTTL = 1 * time.Hour
	AllocationFailureTTL        = 1 * time.Hour
	SKUNotAvailableSpotTTL      = 1 * time.Hour
	SKUNotAvailableOnDemandTTL  = 23 * time.Hour
)

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 GenerateResourceName

func GenerateResourceName(nodeClaimName string) string

func GetAllSingleValuedRequirementLabels

func GetAllSingleValuedRequirementLabels(instanceType *corecloudprovider.InstanceType) map[string]string

GetAllSingleValuedRequirementLabels converts instanceType.Requirements to labels Like instanceType.Requirements.Labels() it uses single-valued requirements Unlike instanceType.Requirements.Labels() it does not filter out restricted Node labels

func GetCapacityType

func GetCapacityType(instance *armcompute.VirtualMachine) string

func GetNICListQueryBuilder added in v0.6.2

func GetNICListQueryBuilder(rg string) *kql.Builder

GetNICListQueryBuilder returns a KQL query builder for listing NICs with nodepool tags

func GetVMListQueryBuilder added in v0.6.2

func GetVMListQueryBuilder(rg string) *kql.Builder

GetVMListQueryBuilder returns a KQL query builder for listing VMs with nodepool tags

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 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                   skuclient.SkuClient
	LoadBalancersClient         loadbalancer.LoadBalancersAPI
	NetworkSecurityGroupsClient networksecuritygroup.API
	// contains filtered or unexported fields
}

TODO: Move this to another package that more correctly reflects its usage across multiple providers

func CreateAZClient

func CreateAZClient(ctx context.Context, cfg *auth.Config, cred azcore.TokenCredential) (*AZClient, error)

func NewAZClient

func NewAZClient(ctx context.Context, cfg *auth.Config, env *azclient.Environment, cred azcore.TokenCredential) (*AZClient, error)

nolint: gocyclo

func NewAZClientFromAPI

func NewAZClientFromAPI(
	virtualMachinesClient VirtualMachinesAPI,
	azureResourceGraphClient AzureResourceGraphAPI,
	virtualMachinesExtensionClient VirtualMachineExtensionsAPI,
	interfacesClient NetworkInterfacesAPI,
	loadBalancersClient loadbalancer.LoadBalancersAPI,
	networkSecurityGroupsClient networksecuritygroup.API,
	imageVersionsClient imagefamilytypes.CommunityGalleryImageVersionsAPI,
	nodeImageVersionsClient imagefamilytypes.NodeImageVersionsAPI,
	nodeBootstrappingClient imagefamilytypes.NodeBootstrappingAPI,
	skuClient skuclient.SkuClient,
) *AZClient

type DefaultProvider added in v0.7.0

type DefaultProvider struct {
	// contains filtered or unexported fields
}

func NewDefaultProvider added in v0.7.0

func NewDefaultProvider(
	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,
) *DefaultProvider

func (*DefaultProvider) BeginCreate added in v1.4.0

func (p *DefaultProvider) 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 (*DefaultProvider) Delete added in v0.7.0

func (p *DefaultProvider) Delete(ctx context.Context, resourceName string) error

func (*DefaultProvider) DeleteNic added in v0.7.2

func (p *DefaultProvider) DeleteNic(ctx context.Context, nicName string) error

func (*DefaultProvider) Get added in v0.7.0

func (*DefaultProvider) GetNic added in v0.7.0

func (p *DefaultProvider) GetNic(ctx context.Context, rg, nicName string) (*armnetwork.Interface, error)

func (*DefaultProvider) List added in v0.7.0

func (*DefaultProvider) ListNics added in v0.7.2

func (p *DefaultProvider) ListNics(ctx context.Context) ([]*armnetwork.Interface, error)

ListNics returns all network interfaces in the resource group that have the nodepool tag

func (*DefaultProvider) Update added in v0.7.0

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)
}

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 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)
}

type VirtualMachinePromise added in v1.4.0

type VirtualMachinePromise struct {
	VM   *armcompute.VirtualMachine
	Wait func() error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL