aks

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

README

AKS Module

This module is responsible for collecting pricing information for AKS clusters.

Pricing Map

Because Azure has not yet implemented the pricing API into it's SDK :shame:, this packages uses the 3rd party Azure Retail Prices SDK to grab the prices.

This is based on Azure's pricing model, where different prices are determined by a combination of those factors.

Price Stratification

The PricingMap is built out with the following structure:

root -> {
  regionName -> {
    machinePriority -> {
      operatingSystem -> {
        skuName -> information
      }
    }
  }
}

That way, in order to uniquely identify a price, we will have to have the following attributes of any VM:

  • the region it is deployed into
  • it's priority (spot or on-demand)
  • the operating system it is running
  • it's SKU (e.g. E8-4as_v4)

Future Work

  • (Pricing Map) - implement background job to populate pricing map every 24 hours
  • (Pricing Map) - clear and repopulate Price Map and cache with backgroud job
  • (Pricing Map) - implement retry mechanism to pricing map, crash program if it doesn't populate after 5 tries
  • (Pricing Map) - implement VM lookup by machine ID
  • (VMs) - implement VM list
  • connect VM list with Pricing Map
  • Prometheus metrics

Documentation

Index

Constants

View Source
const (
	AZ_API_VERSION string = "2023-01-01-preview" // using latest API Version https://learn.microsoft.com/en-us/rest/api/cost-management/retail-prices/azure-retail-prices
)

Variables

View Source
var (
	ErrClientCreationFailure = errors.New("failed to create client")
	ErrPageAdvanceFailure    = errors.New("failed to advance page")
)

Errors

Functions

This section is empty.

Types

type Collector

type Collector struct {
	PriceStore *PriceStore
	// contains filtered or unexported fields
}

Collector is a prometheus collector that collects metrics from AKS clusters.

func New

func New(ctx context.Context, cfg *Config) (*Collector, error)

func (*Collector) Collect

func (c *Collector) Collect(ch chan<- prometheus.Metric) error

Collect satisfies the provider.Collector interface.

func (*Collector) CollectMetrics

func (c *Collector) CollectMetrics(_ chan<- prometheus.Metric) float64

CollectMetrics is a no-op function that satisfies the provider.Collector interface. Deprecated: CollectMetrics is deprecated and will be removed in a future release.

func (*Collector) Describe

func (c *Collector) Describe(ch chan<- *prometheus.Desc) error

func (*Collector) Name

func (c *Collector) Name() string

func (*Collector) Register

func (c *Collector) Register(_ provider.Registry) error

type Config

type Config struct {
	Logger      *slog.Logger
	Credentials *azidentity.DefaultAzureCredential

	SubscriptionId string
}

type MachineOperatingSystem added in v0.1.6

type MachineOperatingSystem int
const (
	Linux MachineOperatingSystem = iota
	Windows
)

func (MachineOperatingSystem) String added in v0.1.6

func (o MachineOperatingSystem) String() string

type MachinePriority added in v0.1.6

type MachinePriority int
const (
	OnDemand MachinePriority = iota
	Spot
)

func (MachinePriority) String added in v0.1.6

func (v MachinePriority) String() string

type PriceByOperatingSystem added in v0.1.6

type PriceByOperatingSystem map[MachineOperatingSystem]PriceBySku

type PriceByPriority added in v0.1.6

type PriceByPriority map[MachinePriority]PriceByOperatingSystem

type PriceBySku added in v0.1.6

type PriceBySku map[string]retailPriceSdk.ResourceSKU

type PriceStore added in v0.1.6

type PriceStore struct {
	RegionMap map[string]PriceByPriority
	Cache     map[string]*retailPriceSdk.ResourceSKU
	// contains filtered or unexported fields
}

func NewPricingStore added in v0.1.6

func NewPricingStore(subId string, priceClient *retailPriceSdk.RetailPricesClient, parentLogger *slog.Logger, parentContext context.Context) *PriceStore

func (*PriceStore) GetVmPrice added in v0.1.6

func (p *PriceStore) GetVmPrice()

TODO - implement ability to lookup a certain VM's Price by it's ID

func (*PriceStore) PopulatePriceStore added in v0.1.6

func (p *PriceStore) PopulatePriceStore(locationList []string) error

Jump to

Keyboard shortcuts

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