trackers

package
v0.11.5 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package trackers feature implementations that help track specific stats about Kubernetes resources, e.g., nodes and pods in the Azure property provider.

Index

Constants

View Source
const (
	// AKSClusterNodeSKULabelName is the node label added by AKS, which indicated the SKU
	// of the node.
	AKSClusterNodeSKULabelName = "beta.kubernetes.io/instance-type"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AKSKarpenterPricingClient

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

AKSKarpenterPricingClient is a thin wrapper around the AKS Karpenter pricing client, which implements the PricingProvider interface.

func NewAKSKarpenterPricingClient

func NewAKSKarpenterPricingClient(ctx context.Context, region string) *AKSKarpenterPricingClient

NewAKSKarpenterPricingClient returns a new AKS Karpenter pricing client, which implements the PricingProvider interface.

func (*AKSKarpenterPricingClient) LastUpdated

func (k *AKSKarpenterPricingClient) LastUpdated() time.Time

LastUpdated returns the last time the pricing information was updated.

func (*AKSKarpenterPricingClient) OnDemandPrice

func (k *AKSKarpenterPricingClient) OnDemandPrice(instanceType string) (float64, bool)

OnDemandPrice returns the on-demand price of an instance type.

type NodeSet

type NodeSet map[string]bool

NodeSet is a set of nodes.

type NodeTracker

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

NodeTracker helps track specific stats about nodes in a Kubernetes cluster, e.g., its count.

func NewNodeTracker

func NewNodeTracker(pp PricingProvider) *NodeTracker

NewNodeTracker returns a node tracker.

func (*NodeTracker) AddOrUpdate

func (nt *NodeTracker) AddOrUpdate(node *corev1.Node)

AddOrUpdate starts tracking a node or updates the stats about a node that has been tracked.

func (*NodeTracker) Costs

func (nt *NodeTracker) Costs() (perCPUCoreCost, perGBMemoryCost float64, err error)

Costs returns the per CPU core and per GB memory costs in the cluster.

func (*NodeTracker) NodeCount

func (nt *NodeTracker) NodeCount() int

NodeCount returns the node count stat that a node tracker tracks.

func (*NodeTracker) Remove

func (nt *NodeTracker) Remove(nodeName string)

Remove stops tracking a node.

func (*NodeTracker) TotalAllocatable

func (nt *NodeTracker) TotalAllocatable() corev1.ResourceList

TotalAllocatable returns the total allocatable capacity of all resources that the node tracker tracks.

func (*NodeTracker) TotalAllocatableFor

func (nt *NodeTracker) TotalAllocatableFor(rn corev1.ResourceName) resource.Quantity

TotalAllocatableFor returns the total allocatable capacity of a specific resource that the node tracker tracks.

func (*NodeTracker) TotalCapacity

func (nt *NodeTracker) TotalCapacity() corev1.ResourceList

TotalCapacity returns the total capacity of all resources that the node tracker tracks.

func (*NodeTracker) TotalCapacityFor

func (nt *NodeTracker) TotalCapacityFor(rn corev1.ResourceName) resource.Quantity

TotalCapacityFor returns the total capacity of a specific resource that the node tracker tracks.

type PodTracker

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

PodTracker helps track specific stats about pods in a Kubernetes cluster, e.g., the sum of its requested resources.

func NewPodTracker

func NewPodTracker() *PodTracker

NewPodTracker returns a pod tracker.

func (*PodTracker) AddOrUpdate

func (pt *PodTracker) AddOrUpdate(pod *corev1.Pod)

AddOrUpdate starts tracking a pod or updates the stats about a pod that has been tracked.

func (*PodTracker) Remove

func (pt *PodTracker) Remove(podIdentifier string)

Remove stops tracking a pod.

func (*PodTracker) TotalRequested

func (pt *PodTracker) TotalRequested() corev1.ResourceList

TotalRequested returns the total requested resources of all resources that the pod tracker tracks.

func (*PodTracker) TotalRequestedFor

func (pt *PodTracker) TotalRequestedFor(rn corev1.ResourceName) resource.Quantity

TotalRequestedFor returns the total requested resources of a specific resource that the pod tracker tracks.

type PricingProvider

type PricingProvider interface {
	OnDemandPrice(instanceType string) (float64, bool)
	LastUpdated() time.Time
}

PricingProvider is an interface that the Azure property provider uses to sync pricing information.

It helps decouple the Azure property provider from the actual pricing provider implementation; even though at this moment the property provider leverages the AKS Karpenter pricing client only.

Jump to

Keyboard shortcuts

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