Documentation ¶
Index ¶
- func QuantityAsFloat64(q resource.Quantity) float64
- type ComputeResources
- func CalculateTotalResource(nodes []*v1.Node) ComputeResources
- func CalculateTotalResourceRequest(pods []*v1.Pod) ComputeResources
- func FromResourceList(list v1.ResourceList) ComputeResources
- func TotalPodResourceLimit(podSpec *v1.PodSpec) ComputeResources
- func TotalPodResourceRequest(podSpec *v1.PodSpec) ComputeResources
- func (a ComputeResources) Add(b ComputeResources)
- func (a ComputeResources) AsFloat() ComputeResourcesFloat
- func (a ComputeResources) DeepCopy() ComputeResources
- func (a ComputeResources) Dominates(b ComputeResources) bool
- func (a ComputeResources) Equal(b ComputeResources) bool
- func (a ComputeResources) IsValid() bool
- func (a ComputeResources) IsZero() bool
- func (a ComputeResources) LimitToZero()
- func (a ComputeResources) Max(b ComputeResources)
- func (a ComputeResources) Mul(factor float64) ComputeResourcesFloat
- func (a ComputeResources) MulByResource(factors map[string]float64) ComputeResourcesFloat
- func (a ComputeResources) String() string
- func (a ComputeResources) Sub(b ComputeResources)
- type ComputeResourcesFloat
- func (a ComputeResourcesFloat) Add(b ComputeResourcesFloat)
- func (a ComputeResourcesFloat) DeepCopy() ComputeResourcesFloat
- func (a ComputeResourcesFloat) IsLessThan(b ComputeResourcesFloat) bool
- func (a ComputeResourcesFloat) IsValid() bool
- func (a ComputeResourcesFloat) LimitToZero()
- func (a ComputeResourcesFloat) LimitWith(limit ComputeResourcesFloat) ComputeResourcesFloat
- func (a ComputeResourcesFloat) Max(b ComputeResourcesFloat)
- func (a ComputeResourcesFloat) MergeWith(merged ComputeResourcesFloat) ComputeResourcesFloat
- func (a ComputeResourcesFloat) Mul(factor float64) ComputeResourcesFloat
- func (a ComputeResourcesFloat) Sub(b ComputeResourcesFloat)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func QuantityAsFloat64 ¶
QuantityAsFloat64 returns a float64 representation of a quantity. We need our own function because q.AsApproximateFloat64 sometimes returns surprising results. For example, resource.MustParse("5188205838208Ki").AsApproximateFloat64() returns 0.004291583283300088, whereas this function returns 5.312722778324993e+15.
Types ¶
type ComputeResources ¶
func CalculateTotalResource ¶
func CalculateTotalResource(nodes []*v1.Node) ComputeResources
func CalculateTotalResourceRequest ¶
func CalculateTotalResourceRequest(pods []*v1.Pod) ComputeResources
func FromResourceList ¶
func FromResourceList(list v1.ResourceList) ComputeResources
func TotalPodResourceLimit ¶
func TotalPodResourceLimit(podSpec *v1.PodSpec) ComputeResources
func TotalPodResourceRequest ¶
func TotalPodResourceRequest(podSpec *v1.PodSpec) ComputeResources
TotalPodResourceRequest represents the resource request for a given pod is the maximum of:
- sum of all containers
- any individual init container
This is because:
- containers run in parallel (so need to sum resources)
- init containers run sequentially (so only their individual resource need be considered)
So pod resource usage is the max for each resource type (cpu/memory etc) that could be used at any given time
func (ComputeResources) Add ¶
func (a ComputeResources) Add(b ComputeResources)
func (ComputeResources) AsFloat ¶
func (a ComputeResources) AsFloat() ComputeResourcesFloat
func (ComputeResources) DeepCopy ¶
func (a ComputeResources) DeepCopy() ComputeResources
func (ComputeResources) Dominates ¶
func (a ComputeResources) Dominates(b ComputeResources) bool
func (ComputeResources) Equal ¶
func (a ComputeResources) Equal(b ComputeResources) bool
func (ComputeResources) IsValid ¶
func (a ComputeResources) IsValid() bool
func (ComputeResources) IsZero ¶ added in v0.3.50
func (a ComputeResources) IsZero() bool
func (ComputeResources) LimitToZero ¶ added in v0.3.50
func (a ComputeResources) LimitToZero()
func (ComputeResources) Max ¶
func (a ComputeResources) Max(b ComputeResources)
func (ComputeResources) Mul ¶
func (a ComputeResources) Mul(factor float64) ComputeResourcesFloat
func (ComputeResources) MulByResource ¶
func (a ComputeResources) MulByResource(factors map[string]float64) ComputeResourcesFloat
func (ComputeResources) String ¶
func (a ComputeResources) String() string
func (ComputeResources) Sub ¶
func (a ComputeResources) Sub(b ComputeResources)
type ComputeResourcesFloat ¶
ComputeResourcesFloat is float version of compute resource, prefer calculations with quantity where possible
func (ComputeResourcesFloat) Add ¶
func (a ComputeResourcesFloat) Add(b ComputeResourcesFloat)
func (ComputeResourcesFloat) DeepCopy ¶
func (a ComputeResourcesFloat) DeepCopy() ComputeResourcesFloat
func (ComputeResourcesFloat) IsLessThan ¶
func (a ComputeResourcesFloat) IsLessThan(b ComputeResourcesFloat) bool
func (ComputeResourcesFloat) IsValid ¶
func (a ComputeResourcesFloat) IsValid() bool
func (ComputeResourcesFloat) LimitToZero ¶
func (a ComputeResourcesFloat) LimitToZero()
func (ComputeResourcesFloat) LimitWith ¶
func (a ComputeResourcesFloat) LimitWith(limit ComputeResourcesFloat) ComputeResourcesFloat
func (ComputeResourcesFloat) Max ¶
func (a ComputeResourcesFloat) Max(b ComputeResourcesFloat)
func (ComputeResourcesFloat) MergeWith ¶
func (a ComputeResourcesFloat) MergeWith(merged ComputeResourcesFloat) ComputeResourcesFloat
MergeWith represents the merged in values take precedence and override existing values for the same key
func (ComputeResourcesFloat) Mul ¶
func (a ComputeResourcesFloat) Mul(factor float64) ComputeResourcesFloat
func (ComputeResourcesFloat) Sub ¶
func (a ComputeResourcesFloat) Sub(b ComputeResourcesFloat)