Documentation ¶
Index ¶
- Constants
- Variables
- type Client
- func (c *Client) GetCostForPersistentVolume(ctx context.Context, cluster string) (Cost, error)
- func (c *Client) GetCostPerCPU(ctx context.Context, cluster string) (Cost, error)
- func (c *Client) GetMemoryCost(ctx context.Context, cluster string) (Cost, error)
- func (c *Client) GetNodeCount(ctx context.Context, cluster string) (int, error)
- type ClientConfig
- type Clients
- type Cluster
- type Cost
- func (c Cost) DollarsForPeriod(p Period, r int64) float64
- func (c Cost) DollarsYearly(memReq int64) float64
- func (c Cost) NonSpotCPUForPeriod(p Period, r int64) float64
- func (c Cost) NonSpotMemoryForPeriod(p Period, r int64) float64
- func (c Cost) NonSpotYearly(cpuReq int64) float64
- func (c Cost) SpotCPUForPeriod(p Period, r int64) float64
- func (c Cost) SpotMemoryForPeriod(p Period, r int64) float64
- func (c Cost) SpotYearly(cpuReq int64) float64
- type CostModel
- type Period
- type PeriodKeys
- type ReportType
- type Reporter
- type Requirements
Constants ¶
const ( Hourly Period = 1 Daily = 24 Weekly = 24 * 7 Monthly = 24 * 30 Yearly = 24 * 365 )
const CommentPrefix = "<!-- kost -->"
CommentPrefix is used to identify and hide old messages on GitHub.
Variables ¶
var ( ErrNoResults = errors.New("no cost results") ErrBadQuery = errors.New("bad query") ErrNilConfig = errors.New("client config is nil") ErrEmptyAddress = errors.New("client address can't be empty") ErrProdConfigMissing = errors.New("prod config is missing") )
ErrNoResults is the error returned when querying for costs returns no results.
var ErrNoReports = errors.New("nothing to report")
var ErrUnknownKind = errors.New("unknown kind")
ErrUnknownKind is the error throw when the kind of the resource in the manifest is unknown to the parser.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a client for the cost model.
func NewClient ¶
func NewClient(config *ClientConfig) (*Client, error)
NewClient creates a new cost model client with the given configuration.
func (*Client) GetCostForPersistentVolume ¶
GetCostForPersistentVolume returns the average cost per persistent volume for a given cluster
func (*Client) GetCostPerCPU ¶
GetCostPerCPU returns the average cost per CPU for a given cluster.
func (*Client) GetMemoryCost ¶
GetMemoryCost returns the cost per memory for a given cluster
type ClientConfig ¶
ClientConfig is the configuration for the cost model client.
type Clients ¶
Clients bundles the dev and prod client in one struct.
func NewClients ¶
func NewClients(prodConfig, devConfig *ClientConfig) (*Clients, error)
NewClients creates a new cost model clients with the given configuration.
type Cost ¶
Cost represents the _hourly_ cost of a resource in USD. If the cluster does not have pricing data for spot nodes, then Dollars will be set.
func (Cost) DollarsForPeriod ¶
DollarsForPeriod returns the cost of a resource in USD for a given period. Primarily used by PersistentVolumeClaims which do not have spot/non spot pricing.
func (Cost) DollarsYearly ¶
func (Cost) NonSpotMemoryForPeriod ¶
func (Cost) NonSpotYearly ¶
func (Cost) SpotYearly ¶
type CostModel ¶
CostModel represents the cost of each resource for a specific cluster
func GetCostModelForCluster ¶
func (*CostModel) TotalCostForPeriod ¶
func (c *CostModel) TotalCostForPeriod(p Period, r Requirements) float64
TotalCostForPeriod calculates the costs of each resource on the CostModel and returns the sum of the costs
type PeriodKeys ¶
type ReportType ¶
type ReportType string
const ( Table ReportType = "table" Summary ReportType = "summary" Markdown ReportType = "markdown" )
type Reporter ¶
func (*Reporter) AddReport ¶
func (r *Reporter) AddReport(costModel *CostModel, from, to Requirements)
AddReport adds a costmodel and associated from, to resources to the reporter.
type Requirements ¶
type Requirements struct { CPU int64 Memory int64 PersistentVolume int64 Kind string Namespace string Name string }
Requirements is a struct that holds the aggergated amount of resources for a given manifest file. CPU and Memory are in millicores and bytes respectively and are the sum of all containers in a pod. TODO: Calculate the amount of persistent volume required for a given manifest. This will require finding the associated PVC and calculating the size of the volume.
func Delta ¶
func Delta(from, to Requirements) Requirements
Delta returns the difference between two resources. A positive value signals that the resource has increased. A negative value signals that the resource has decreased.
func ParseManifest ¶
func ParseManifest(src []byte, costModel *CostModel) (Requirements, error)
ParseManifest will parse a manifest file and return the aggregated amount of resources requested. The manifest can be a Deployment, StatefulSet, DaemonSet, Cronjob, Job, or Pod. If the manifest has the number of Replicas, the total resources will be multiplied by the number of replicas.
func (*Requirements) AddRequirements ¶
func (r *Requirements) AddRequirements(reqs corev1.ResourceRequirements)
AddRequirements will increment the resources by the amount specified in the given requirements.