resource

package
v0.3.47 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func QuantityAsFloat64

func QuantityAsFloat64(q resource.Quantity) float64

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

type ComputeResources map[string]resource.Quantity

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 (ComputeResources) AsFloat

func (ComputeResources) DeepCopy

func (a ComputeResources) DeepCopy() ComputeResources

func (ComputeResources) Dominates

func (a ComputeResources) Dominates(b ComputeResources) bool

func (ComputeResources) Equal

func (ComputeResources) IsValid

func (a ComputeResources) IsValid() bool

func (ComputeResources) Max

func (ComputeResources) Mul

func (ComputeResources) MulByResource

func (a ComputeResources) MulByResource(factors map[string]float64) ComputeResourcesFloat

func (ComputeResources) String

func (a ComputeResources) String() string

func (ComputeResources) Sub

type ComputeResourcesFloat

type ComputeResourcesFloat map[string]float64

ComputeResourcesFloat is float version of compute resource, prefer calculations with quantity where possible

func (ComputeResourcesFloat) Add

func (ComputeResourcesFloat) DeepCopy

func (ComputeResourcesFloat) IsLessThan

func (ComputeResourcesFloat) IsValid

func (a ComputeResourcesFloat) IsValid() bool

func (ComputeResourcesFloat) LimitToZero

func (a ComputeResourcesFloat) LimitToZero()

func (ComputeResourcesFloat) LimitWith

func (ComputeResourcesFloat) Max

func (ComputeResourcesFloat) MergeWith

MergeWith represents the merged in values take precedence and override existing values for the same key

func (ComputeResourcesFloat) Mul

func (ComputeResourcesFloat) Sub

Jump to

Keyboard shortcuts

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