common

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: May 4, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PodRequestsAndLimits

func PodRequestsAndLimits(pod *v1.Pod) (reqs, limits v1.ResourceList)

PodRequestsAndLimits returns a dictionary of all defined resources summed up for all containers of the pod. If PodOverhead feature is enabled, pod overhead is added to the total container resource requests and to the total container limits which have a non-zero quantity.

func PodRequestsAndLimitsReuse

func PodRequestsAndLimitsReuse(pod *v1.Pod, reuseReqs, reuseLimits v1.ResourceList) (reqs, limits v1.ResourceList)

PodRequestsAndLimitsReuse returns a dictionary of all defined resources summed up for all containers of the pod. If PodOverhead feature is enabled, pod overhead is added to the total container resource requests and to the total container limits which have a non-zero quantity. The caller may avoid allocations of resource lists by passing a requests and limits list to the function, which will be cleared before use.

func PodRequestsAndLimitsWithoutOverhead

func PodRequestsAndLimitsWithoutOverhead(pod *v1.Pod) (reqs, limits v1.ResourceList)

PodRequestsAndLimitsWithoutOverhead will create a dictionary of all defined resources summed up for all containers of the pod.

Types

type CustomResources

type CustomResources map[corev1.ResourceName]resource.Quantity

CustomResources is a key-value map for defining custom resources

func (CustomResources) DeepCopy

func (cr CustomResources) DeepCopy() CustomResources

DeepCopy copy the custom resource

func (CustomResources) Equal

func (cr CustomResources) Equal(other CustomResources) bool

Equal return if resources is equal

type ProviderNode

type ProviderNode struct {
	sync.Mutex
	*corev1.Node
}

func (*ProviderNode) AddResource

func (n *ProviderNode) AddResource(resource *Resource) error

AddResource add resource to the node

func (*ProviderNode) DeepCopy

func (n *ProviderNode) DeepCopy() *corev1.Node

DeepCopy deepcopy node with lock, to avoid concurrent read-write

func (*ProviderNode) SubResource

func (n *ProviderNode) SubResource(resource *Resource) error

SubResource sub resource from the node

type Resource

type Resource struct {
	// CPU requirement
	CPU resource.Quantity
	// Memory requirement
	Memory resource.Quantity
	// Pods requirement
	Pods resource.Quantity
	// EphemeralStorage requirement
	EphemeralStorage resource.Quantity
	// Custom resource requirement
	Custom CustomResources
}

Resource defines the resources of a pod, it provides func `Add`, `Sub` to make computation flexible

func ConvertResource

func ConvertResource(resources corev1.ResourceList) *Resource

ConvertResource converts ResourceList to Resource

func NewResource

func NewResource() *Resource

NewResource returns A resource struct

func (*Resource) Add

func (r *Resource) Add(nc *Resource)

Add adds resource to the current one

func (*Resource) Equal

func (r *Resource) Equal(other *Resource) bool

Equal is for two resources comparision

func (*Resource) SetCapacityToNode

func (r *Resource) SetCapacityToNode(node *corev1.Node)

SetCapacityToNode set the resource the virtual-kubelet node

func (*Resource) Sub

func (r *Resource) Sub(nc *Resource)

Sub subs resource from the current one

Jump to

Keyboard shortcuts

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