Documentation
¶
Index ¶
- type ComputeResources
- func CalculateTotalResource(nodes []*v1.Node) ComputeResources
- func CalculateTotalResourceRequest(pods []*v1.Pod) ComputeResources
- func FromProtoMap(m map[string]*resource.Quantity) ComputeResources
- func FromResourceList(list v1.ResourceList) ComputeResources
- func TotalPodResourceRequest(podSpec *v1.PodSpec) ComputeResources
- func (a ComputeResources) Add(b ComputeResources)
- func (a ComputeResources) AsKubernetesResourceList() v1.ResourceList
- func (a ComputeResources) DeepCopy() ComputeResources
- func (a ComputeResources) Div(b map[string]int64)
- 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) String() string
- func (a ComputeResources) Sub(b ComputeResources)
- func (a ComputeResources) ToProtoMap() map[string]*resource.Quantity
- func (a ComputeResources) Zero()
- type ComputeResourcesFloat
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ComputeResources ¶
func CalculateTotalResource ¶
func CalculateTotalResource(nodes []*v1.Node) ComputeResources
CalculateTotalResource computes the combined total quantity of each resource (cpu, memory, etc) available for scheduling in the slice of nodes supplied as argument in the function.
func CalculateTotalResourceRequest ¶
func CalculateTotalResourceRequest(pods []*v1.Pod) ComputeResources
CalculateTotalResourceRequest computes the combined total quantity of each resource (cpu, memory, etc) requested by each pod in the slice of pods supplied as argument in the function.
func FromProtoMap ¶ added in v0.8.7
func FromProtoMap(m map[string]*resource.Quantity) ComputeResources
func FromResourceList ¶
func FromResourceList(list v1.ResourceList) ComputeResources
FromResourceList function takes a map with keys of type ResourceName and values of type "resource.Quantity" as defined in the K8s API.
It converts the keys to strings and creates a new map with the same keys, but with deep copies of the values. The resulting map is of type map[string]resource.Quantity.
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) AsKubernetesResourceList ¶ added in v0.19.10
func (a ComputeResources) AsKubernetesResourceList() v1.ResourceList
func (ComputeResources) DeepCopy ¶
func (a ComputeResources) DeepCopy() ComputeResources
func (ComputeResources) Div ¶ added in v0.16.9
func (a ComputeResources) Div(b map[string]int64)
func (ComputeResources) Dominates ¶
func (a ComputeResources) Dominates(b ComputeResources) bool
Dominates function compares two ComputeResources maps, a and b, to determine whether "a" is sufficient to meet or exceed the resource quantity of b if it does then "true" is returned if not "false" is returned.
func (ComputeResources) Equal ¶
func (a ComputeResources) Equal(b ComputeResources) bool
Equal function compares a and b, returns false:
- if both are nil.
- if they have different lengths
- if a key exists in "a" but does not exist in "b" or vice versa.
func (ComputeResources) IsValid ¶
func (a ComputeResources) IsValid() bool
IsValid function checks if all the values in "a" is greater than or equal to zero. It returns true if all values are valid i.e. all values are greater than or equal to zero, and false if any of the values are negative
func (ComputeResources) IsZero ¶ added in v0.3.50
func (a ComputeResources) IsZero() bool
IsZero function checks if every value in "a" is zero. If any value is not zero it returns false, if all are zero, it returns true.
func (ComputeResources) LimitToZero ¶ added in v0.3.50
func (a ComputeResources) LimitToZero()
LimitToZero function limits each value in "a" to a minimum value of zero. In the case any value in "a" has a value less than zero, it is replaced with a value of zero.
func (ComputeResources) Max ¶
func (a ComputeResources) Max(b ComputeResources)
Max function checks if the key in the ComputeResources Map supplied as an argument, b exists and has a value greater than the already existing value mapped to the key in ComputeResources Map supplied as the method's target, "a", if so, the value of the key is replaced by b's value. If the key does not exist in "a", it is created and made to have a DeepCopy value of its value in b.
func (ComputeResources) String ¶
func (a ComputeResources) String() string
String function handles the string representation of ComputeResources i.e. how the output of the struct is represented when functions like fmt.Print() is called on it.
func (ComputeResources) Sub ¶
func (a ComputeResources) Sub(b ComputeResources)
The Sub function subtracts the values in "a" from the values in "b". In the case a value exists in "b" but not in "a", the negative of the value is mapped to its key in "a". The Sub function can be visually represented as (a - b).
func (ComputeResources) ToProtoMap ¶ added in v0.8.7
func (a ComputeResources) ToProtoMap() map[string]*resource.Quantity
func (ComputeResources) Zero ¶ added in v0.16.10
func (a ComputeResources) Zero()
Zero zeroes out rl such that all quantities have value 0.
type ComputeResourcesFloat ¶
ComputeResourcesFloat is float version of compute resource, prefer calculations with quantity where possible