Documentation ¶
Index ¶
- Constants
- Variables
- type ClusterConfig
- type Container
- type Cost
- type CostRange
- type CostimatorConfig
- type DaemonSet
- type Deployment
- type DiffCost
- type DiffCostRange
- type GCPPriceCatalog
- type GroupVersionKind
- type HPA
- type HorizontalScalableResource
- type MachineFamily
- type Manifests
- type PriceDetails
- type PriceDiff
- type PriceMaxDiff
- type PriceSummary
- type ReplicaSet
- type Resource
- type ResourceConfig
- type ResourcePrice
- type StatefulSet
- type StoragePrice
- type VolumeClaim
Constants ¶
const ( // HPAKind just to avoid mispeling HPAKind = "HorizontalPodAutoscaler" // DeploymentKind is just to avoid mispeling DeploymentKind = "Deployment" // ReplicaSetKind is just to avoid mispeling ReplicaSetKind = "ReplicaSet" // StatefulSetKind is just to avoid mispeling StatefulSetKind = "StatefulSet" // DaemonSetKind is just to avoid mispeling DaemonSetKind = "DaemonSet" // VolumeClaimKind is just to avoid mispeling VolumeClaimKind = "PersistentVolumeClaim" )
Variables ¶
var SupportedKinds = []string{HPAKind, DeploymentKind, ReplicaSetKind, StatefulSetKind, DaemonSetKind, VolumeClaimKind}
SupportedKinds groups all supported kinds
Functions ¶
This section is empty.
Types ¶
type ClusterConfig ¶
type ClusterConfig struct {
NodesCount int32 `yaml:"nodesCount,omitempty"`
}
ClusterConfig is used to setup defaults for cluster
type Container ¶
Container is the simplified representation of k8s Container Client doesn't need to handle different version and the complexity of k8s.io package
type Cost ¶
type Cost struct {
MonthlyRanges []CostRange
}
Cost groups cost range by kinda
func (*Cost) MonthlyTotal ¶
MonthlyTotal returns the sum for all MonthlyRanges
type CostRange ¶
type CostRange struct { Kind string `json:"kind"` MinRequested float64 `json:"minRequested"` MaxRequested float64 `json:"maxRequested"` HPABuffer float64 `json:"hpaBuffer"` //Note: currently only supports CPU Target utilizaiton MinLimited float64 `json:"minLimited"` MaxLimited float64 `json:"maxLimited"` }
CostRange represent the range of estimated value
func (*CostRange) Subtract ¶
func (c *CostRange) Subtract(costRangePrev CostRange) DiffCostRange
Subtract subtracts the given costrange to the current costrange
type CostimatorConfig ¶
type CostimatorConfig struct { ResourceConf ResourceConfig `yaml:"resourceConf,omitempty"` ClusterConf ClusterConfig `yaml:"clusterConf,omitempty"` }
CostimatorConfig Defaults for not provided info in manifests
func ConfigDefaults ¶
func ConfigDefaults() CostimatorConfig
ConfigDefaults set default values for config
type DaemonSet ¶
DaemonSet is the simplified reprsentation of k8s DaemonSet Client doesn't need to handle different version and the complexity of k8s.io package
type Deployment ¶
type Deployment struct { APIVersionKindName string Replicas int32 Containers []Container // contains filtered or unexported fields }
Deployment is the simplified reprsentation of k8s deployment Client doesn't need to handle different version and the complexity of k8s.io package
type DiffCost ¶
type DiffCost struct { Summary string CostCurr Cost CostPrev Cost MonthlyDiffRange DiffCostRange // contains filtered or unexported fields }
DiffCost holds the total difference between two costs
func (*DiffCost) ToMarkdown ¶
ToMarkdown convert to Markdown string
type DiffCostRange ¶
type DiffCostRange struct { Kind string CostCurr CostRange CostPrev CostRange DiffValue CostRange DiffPercentage CostRange }
DiffCostRange holds the total difference between two costs
func (*DiffCostRange) ToMarkdown ¶
func (d *DiffCostRange) ToMarkdown() string
ToMarkdown convert to Markdown string
func (*DiffCostRange) ToPriceDetails ¶
func (d *DiffCostRange) ToPriceDetails() PriceDetails
ToPriceDetails struct
func (*DiffCostRange) ToPriceDiff ¶
func (d *DiffCostRange) ToPriceDiff() PriceDiff
ToPriceDiff struct
func (*DiffCostRange) ToPriceMaxDiff ¶
func (d *DiffCostRange) ToPriceMaxDiff() PriceMaxDiff
ToPriceMaxDiff struct
func (*DiffCostRange) ToPriceSummary ¶
func (d *DiffCostRange) ToPriceSummary() PriceSummary
ToPriceSummary struct
type GCPPriceCatalog ¶
type GCPPriceCatalog struct {
// contains filtered or unexported fields
}
GCPPriceCatalog implementation to make call to GCP CloudCatalog
func NewGCPPriceCatalog ¶
func NewGCPPriceCatalog(credentials []byte, conf CostimatorConfig) (GCPPriceCatalog, error)
NewGCPPriceCatalog creates a gcpResourcePrice struct with Monthly prices for cpu and memory If credentials is nil, then the default service account will be used
func (*GCPPriceCatalog) CPUMonthlyPrice ¶
func (pc *GCPPriceCatalog) CPUMonthlyPrice() float32
CPUMonthlyPrice returns the GCP CPU price in USD
func (*GCPPriceCatalog) MemoryMonthlyPrice ¶
func (pc *GCPPriceCatalog) MemoryMonthlyPrice() float32
MemoryMonthlyPrice returns the GCP Memory price in USD
func (*GCPPriceCatalog) PdStandardMonthlyPrice ¶
func (pc *GCPPriceCatalog) PdStandardMonthlyPrice() float32
PdStandardMonthlyPrice returns the GCP Storage PD price in USD
type GroupVersionKind ¶
GroupVersionKind is the reprsentation of k8s type This object is used to to avoid sprawl of dependent library (eg. apimachinary) across the code This will allow easy migration to others library (eg. kyaml) in the future once the dependency is all encapulated into k8s_decoder.go
type HPA ¶
type HPA struct { APIVersionKindName string TargetRef string MinReplicas int32 MaxReplicas int32 TargetCPUPercentage int32 }
HPA is the simplified reprsentation of k8s HPA Client doesn't need to handle different version and the complexity of k8s.io package
type HorizontalScalableResource ¶
type HorizontalScalableResource interface {
// contains filtered or unexported methods
}
HorizontalScalableResource is a Horizontal Scalable Resource Implemented by Deployment, ReplicaSet and StatefulSet
type MachineFamily ¶
type MachineFamily string
MachineFamily type
const ( // E2 machines E2 MachineFamily = "E2" // N1 machines N1 MachineFamily = "N1" // N2 machines N2 MachineFamily = "N2" // N2D machines N2D MachineFamily = "N2D" )
type Manifests ¶
type Manifests struct { Deployments []*Deployment ReplicaSets []*ReplicaSet StatefulSets []*StatefulSet DaemonSets []*DaemonSet VolumeClaims []*VolumeClaim // contains filtered or unexported fields }
Manifests holds all deployments and executes cost estimation
func (*Manifests) EstimateCost ¶
func (m *Manifests) EstimateCost(pc GCPPriceCatalog) Cost
EstimateCost loop through all resources and group it by kind
func (*Manifests) LoadObjects ¶
func (m *Manifests) LoadObjects(data []byte, conf CostimatorConfig) error
LoadObjects allow you to decode and load into Manifests your k8s objects For now, it only understands Deployment and HPA
func (*Manifests) LoadObjectsFromPath ¶
func (m *Manifests) LoadObjectsFromPath(path string, conf CostimatorConfig) error
LoadObjectsFromPath loads all files from folder and subfolder finishing with yaml or yml
type PriceDetails ¶
PriceDetails ...
type PriceDiff ¶
type PriceDiff struct { Summary PriceSummary `json:"summary"` Details PriceDetails `json:"details"` }
PriceDiff ...
type PriceMaxDiff ¶
PriceMaxDiff ...
type PriceSummary ¶
type PriceSummary struct { PossiblyCostIncrease bool `json:"possiblyCostIncrease"` MaxDiff PriceMaxDiff `json:"maxDiff"` }
PriceSummary ...
type ReplicaSet ¶
type ReplicaSet struct { APIVersionKindName string Replicas int32 Containers []Container // contains filtered or unexported fields }
ReplicaSet is the simplified reprsentation of k8s replicaset Client doesn't need to handle different version and the complexity of k8s.io package
type Resource ¶
Resource is the simplified reprsentation of k8s Resource Client doesn't need to handle different version and the complexity of k8s.io package
type ResourceConfig ¶
type ResourceConfig struct { MachineFamily MachineFamily `yaml:"machineFamily,omitempty"` Region string `yaml:"region,omitempty"` DefaultCPUinMillis int64 `yaml:"defaultCPUinMillis,omitempty"` DefaultMemoryinBytes int64 `yaml:"defaultMemoryinBytes,omitempty"` PercentageIncreaseForUnboundedRerouces int64 `yaml:"percentageIncreaseForUnboundedRerouces,omitempty"` }
ResourceConfig is used to setup defaults for resources
type ResourcePrice ¶
ResourcePrice interface
type StatefulSet ¶
type StatefulSet struct { APIVersionKindName string Replicas int32 Containers []Container VolumeClaims []*VolumeClaim // contains filtered or unexported fields }
StatefulSet is the simplified reprsentation of k8s StatefulSet Client doesn't need to handle different version and the complexity of k8s.io package
type StoragePrice ¶
type StoragePrice interface {
PdStandardMonthlyPrice() float32
}
StoragePrice interface