query

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddQueryBackendOptionsFlags added in v0.5.0

func AddQueryBackendOptionsFlags(cmd *cobra.Command, options *QueryBackendOptions)

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 QueryClusterID added in v0.5.0

func QueryClusterID(p ClusterInfoParameters) (string, error)

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 ClusterInfoParameters added in v0.5.0

type ClusterInfoParameters struct {
	Ctx context.Context

	QueryBackendOptions
}

type CostPrediction added in v0.5.0

type CostPrediction struct {
	TotalMonthlyRate float64 `json:"totalMonthlyRate"`
	CPUMonthlyRate   float64 `json:"cpuMonthlyRate"`
	RAMMonthlyRate   float64 `json:"ramMonthlyRate"`
	GPUMonthlyRate   float64 `json:"gpuMonthlyRate"`

	MonthlyCPUCoreHours float64 `json:"monthlyCPUCoreHours"`
	MonthlyRAMByteHours float64 `json:"monthlyRAMByteHours"`
	MonthlyGPUHours     float64 `json:"monthlyGPUHours"`
}

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 Spec Cost Prediction queries.
	// e.g. "/prediction/speccost"
	PredictSpecCostPath 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 SpecCostDiff added in v0.5.0

type SpecCostDiff struct {
	Namespace      string `json:"namespace"`
	ControllerKind string `json:"controllerKind"`
	ControllerName string `json:"controllerName"`

	CostBefore CostPrediction `json:"costBefore"`
	CostAfter  CostPrediction `json:"costAfter"`
	CostChange CostPrediction `json:"costChange"`
}

type SpecCostParameters added in v0.5.0

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

	SpecBytes   []byte
	QueryParams map[string]string

	QueryBackendOptions
}

type SpecCostResponse added in v0.5.0

type SpecCostResponse = []SpecCostDiff

func QuerySpecCost added in v0.5.0

func QuerySpecCost(p SpecCostParameters) (SpecCostResponse, error)

Jump to

Keyboard shortcuts

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