query

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func QueryAllocation

func QueryAllocation(p AllocationParameters) ([]map[string]kubecost.Allocation, error)

QueryAllocation queries the Allocation API by proxying a request to Kubecost through the Kubernetes API server if useProxy is true or, if it isn't, by temporarily port forwarding to a Kubecost pod.

func QueryAssets added in v0.2.4

func QueryAssets(p AssetParameters) ([]map[string]AssetNode, error)

QueryAssets queries /model/assets by proxying a request to Kubecost through the Kubernetes API server if useProxy is true or, if it isn't, by temporarily port forwarding to a Kubecost pod.

func QueryCurrencyCode added in v0.1.9

func QueryCurrencyCode(p CurrencyCodeParameters) (string, error)

Types

type AllocationParameters added in v0.2.1

type AllocationParameters struct {
	Ctx context.Context

	QueryParams map[string]string

	QueryBackendOptions
}

type AssetNode added in v0.2.4

type AssetNode struct {
	Type         string                   `json:"type"`
	Properties   kubecost.AssetProperties `json:"properties"`
	Labels       kubecost.AssetLabels     `json:"labels"`
	Start        string                   `json:"start"`
	End          string                   `json:"end"`
	Minutes      float64                  `json:"minutes"`
	NodeType     string                   `json:"nodeType"`
	CpuCores     float64                  `json:"cpuCores"`
	RamBytes     float64                  `json:"ramBytes"`
	CPUCoreHours float64                  `json:"cpuCoreHours"`
	RAMByteHours float64                  `json:"ramByteHours"`
	GPUHours     float64                  `json:"GPUHours"`
	CPUBreakdown kubecost.Breakdown       `json:"cpuBreakdown"`
	GPUBreakdown kubecost.Breakdown       `json:"ramBreakdown"`
	Preemptible  float64                  `json:"preemptible"`
	Discount     float64                  `json:"discount"`
	CPUCost      float64                  `json:"cpuCost"`
	GPUCost      float64                  `json:"gpuCost"`
	GPUCount     float64                  `json:"gpuCount"`
	RAMCost      float64                  `json:"ramCost"`
	Adjustment   float64                  `json:"adjustment"`
	TotalCost    float64                  `json:"totalCost"`
}

type AssetParameters added in v0.2.4

type AssetParameters struct {
	Ctx context.Context

	Window             string
	Aggregate          string
	DisableAdjustments bool
	Accumulate         string
	FilterTypes        string

	QueryBackendOptions
}

type CurrencyCodeParameters added in v0.2.1

type CurrencyCodeParameters struct {
	Ctx context.Context

	QueryBackendOptions
}

type PortForwardQuerier added in v0.3.0

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

func CreatePortForwardForService added in v0.3.0

func CreatePortForwardForService(restConfig *rest.Config, namespace, serviceName string, servicePort int, ctx context.Context) (*PortForwardQuerier, error)

func (*PortForwardQuerier) Stop added in v0.3.0

func (pfq *PortForwardQuerier) Stop()

Stop ends the port forward session.

type QueryBackendOptions added in v0.2.7

type QueryBackendOptions struct {
	// If set, will proxy a request through the K8s API server
	// instead of port forwarding.
	UseProxy bool

	// HelmReleaseName is used to template into service name/etc. to require
	// less flags if Kubecost is installed in a non-"kubecost" namespace.
	//
	// Defaults to "kubecost".
	HelmReleaseName string

	// The name of the K8s service for Kubecost. By default, this is templated
	// from HelmReleaseName.
	ServiceName string

	// The namespace in which Kubecost is running. By default, this is templated
	// from HelmReleaseName.
	KubecostNamespace string

	// The port at which the Service should be queried
	ServicePort int

	// A path which can serve Allocation queries, e.g. "/model/allocation"
	AllocationPath string

	// A path which can serve Resource Cost Prediction queries,
	// e.g. "/prediction/resourcecost"
	PredictResourceCostPath string
	// A path which can serve Resource Cost Prediction queries with diff,
	// e.g. "/prediction/resourcecostdiff"
	PredictResourceCostDiffPath string
	// contains filtered or unexported fields
}

QueryBackendOptions holds common options for managing the query backend used by kubectl-cost, like service name, namespace, etc.

func (*QueryBackendOptions) Complete added in v0.3.0

func (o *QueryBackendOptions) Complete(restConfig *rest.Config) error

func (*QueryBackendOptions) Validate added in v0.3.0

func (o *QueryBackendOptions) Validate() error

type ResourceCostDiffPredictionResponse added in v0.4.0

type ResourceCostDiffPredictionResponse struct {
	MonthlyCostMemory float64 `json:"monthlyCostMemory"`
	MonthlyCostCPU    float64 `json:"monthlyCostCPU"`
	MonthlyCostGPU    float64 `json:"monthlyCostGPU"`
	MonthlyCostTotal  float64 `json:"monthlyCostTotal"`

	MonthlyCostMemoryDiff float64 `json:"monthlyCostMemoryDiff"`
	MonthlyCostCPUDiff    float64 `json:"monthlyCostCPUDiff"`
}

func QueryPredictResourceCostDiff added in v0.4.0

type ResourceCostPredictionResponse added in v0.3.0

type ResourceCostPredictionResponse struct {
	DerivedCostPerCPUCoreHour    float64 `json:"derivedCostPerCPUCoreHour"`
	DerivedCostPerMemoryByteHour float64 `json:"derivedCostPerMemoryByteHour"`
	DerivedCostPerGPUHour        float64 `json:"derivedCostPerGPUHour"`

	MonthlyCPUCoreHours    float64 `json:"monthlyCPUCoreHours"`
	MonthlyMemoryByteHours float64 `json:"monthlyMemoryByteHours"`
	MonthlyGPUHours        float64 `json:"monthlyGPUHours"`

	MonthlyCostMemory float64 `json:"monthlyCostMemory"`
	MonthlyCostCPU    float64 `json:"monthlyCostCPU"`
	MonthlyCostGPU    float64 `json:"monthlyCostGPU"`
	MonthlyCostTotal  float64 `json:"monthlyCostTotal"`
}

func QueryPredictResourceCost added in v0.3.0

func QueryPredictResourceCost(p ResourcePredictParameters) (ResourceCostPredictionResponse, error)

type ResourceDiffPredictParameters added in v0.4.0

type ResourceDiffPredictParameters struct {
	RestConfig *rest.Config
	Ctx        context.Context

	QueryParams map[string]string

	QueryBackendOptions
}

type ResourcePredictParameters added in v0.3.0

type ResourcePredictParameters struct {
	RestConfig *rest.Config
	Ctx        context.Context

	QueryParams map[string]string

	QueryBackendOptions
}

Jump to

Keyboard shortcuts

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