Version: v1.3.0 Latest Latest

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

Go to latest
Published: Aug 14, 2023 License: Apache-2.0 Imports: 32 Imported by: 1




View Source
const (
	EvictionKind            = "Eviction"
	EvictionGroupName       = "policy"
	EvictionSubResourceName = "pods/eviction"



func AddResourceList added in v1.1.0

func AddResourceList(list, newList corev1.ResourceList)

AddResourceList adds the resources in newList to list.

func AppendHostPorts added in v1.3.0

func BoolToFloat64 added in v1.3.0

func BoolToFloat64(b bool) float64

func CloneHostPorts added in v1.3.0

func CloneHostPorts(ports framework.HostPortInfo) framework.HostPortInfo

func DumpJSON

func DumpJSON(o interface{}) string

DumpJSON returns the JSON encoding

func EvictPodByVersion added in v1.2.0

func EvictPodByVersion(ctx context.Context, kubernetes kubernetes.Interface, namespace, name string, opts metav1.DeleteOptions, evictVersion string) error

EvictPodByVersion evicts Pods using the best available method in Kubernetes.

The available methods are, in order of preference: * v1 eviction API * v1beta1 eviction API

func FindContainerIdAndStatusByName added in v0.2.0

func FindContainerIdAndStatusByName(status *corev1.PodStatus, name string) (string, *corev1.ContainerStatus, error)

func FindSupportedEvictVersion added in v1.2.0

func FindSupportedEvictVersion(client kubernetes.Interface) (version string, err error)

func GenerateNodeKey added in v0.7.0

func GenerateNodeKey(node *metav1.ObjectMeta) string

GenerateNodeKey returns a generated key with given meta

func GeneratePodPatch added in v0.7.0

func GeneratePodPatch(oldPod, newPod *corev1.Pod) ([]byte, error)

func GenerateReservationPatch added in v0.7.0

func GenerateReservationPatch(oldReservation, newReservation *schedulingv1alpha1.Reservation) ([]byte, error)

func GetBatchMemoryFromResourceList added in v1.1.1

func GetBatchMemoryFromResourceList(r corev1.ResourceList) int64

func GetBatchMilliCPUFromResourceList added in v1.1.1

func GetBatchMilliCPUFromResourceList(r corev1.ResourceList) int64

func GetCPUSetFromPod added in v1.0.0

func GetCPUSetFromPod(podAnnotations map[string]string) (string, error)

func GetContainerBatchMemoryByteLimit added in v0.7.0

func GetContainerBatchMemoryByteLimit(c *corev1.Container) int64

func GetContainerBatchMemoryByteRequest added in v0.7.0

func GetContainerBatchMemoryByteRequest(c *corev1.Container) int64

func GetContainerBatchMilliCPULimit added in v0.7.0

func GetContainerBatchMilliCPULimit(c *corev1.Container) int64

func GetContainerBatchMilliCPURequest added in v0.7.0

func GetContainerBatchMilliCPURequest(c *corev1.Container) int64

func GetContainerExtendedResources added in v1.1.0

func GetContainerExtendedResources(container *corev1.Container) *apiext.ExtendedResourceContainerSpec

func GetContainerMemoryByteLimit added in v0.3.0

func GetContainerMemoryByteLimit(c *corev1.Container) int64

func GetContainerMilliCPULimit added in v0.3.0

func GetContainerMilliCPULimit(c *corev1.Container) int64

func GetContainerTargetExtendedResources added in v1.1.0

func GetContainerTargetExtendedResources(container *corev1.Container, resourceNames ...corev1.ResourceName) *apiext.ExtendedResourceContainerSpec

GetContainerTargetExtendedResources gets the resource requirements of a container with given extended resources. It returns nil if container is nil or specifies no extended resource.

func GetEmptyContainerExtendedResources added in v1.1.0

func GetEmptyContainerExtendedResources() *apiext.ExtendedResourceContainerSpec

func GetEmptyPodExtendedResources added in v1.1.0

func GetEmptyPodExtendedResources() *apiext.ExtendedResourceSpec

func GetFastLabelSelector

func GetFastLabelSelector(ps *metav1.LabelSelector) (labels.Selector, error)

func GetKubeQosClass added in v0.2.0

func GetKubeQosClass(pod *corev1.Pod) corev1.PodQOSClass

GetKubeQosClass gets the Kubernetes QOSClass for the pod. DEPRECATED: use extension.GetKubeQosClass instead.

func GetNamespacedName added in v1.3.0

func GetNamespacedName(namespace, name string) string

func GetNodeAddress added in v0.4.1

func GetNodeAddress(node *corev1.Node, addrType corev1.NodeAddressType) (string, error)

GetNodeAddress get node specified type address.

func GetNodeAnnoReservedJson added in v1.2.0

func GetNodeAnnoReservedJson(reserved apiext.NodeReservation) string

func GetNodeReservationFromAnnotation added in v1.2.0

func GetNodeReservationFromAnnotation(anno map[string]string) corev1.ResourceList

func GetNodeReservationResources added in v1.3.0

func GetNodeReservationResources(reservation *apiext.NodeReservation) (corev1.ResourceList, error)

func GetPodBEMemoryByteLimit added in v0.2.0

func GetPodBEMemoryByteLimit(pod *corev1.Pod) int64

func GetPodBEMemoryByteRequestIgnoreUnlimited added in v0.3.0

func GetPodBEMemoryByteRequestIgnoreUnlimited(pod *corev1.Pod) int64

func GetPodBEMilliCPULimit added in v0.2.0

func GetPodBEMilliCPULimit(pod *corev1.Pod) int64

func GetPodBEMilliCPURequest added in v0.2.0

func GetPodBEMilliCPURequest(pod *corev1.Pod) int64

func GetPodExtendedResources added in v1.1.0

func GetPodExtendedResources(pod *corev1.Pod) *apiext.ExtendedResourceSpec

func GetPodKey

func GetPodKey(pod *corev1.Pod) string

func GetPodMetricKey

func GetPodMetricKey(podMetric *slov1alpha1.PodMetricInfo) string

func GetPodMilliCPULimit added in v0.7.0

func GetPodMilliCPULimit(pod *corev1.Pod) int64

func GetPodRequest

func GetPodRequest(pod *corev1.Pod, resourceNames ...corev1.ResourceName) corev1.ResourceList

func GetPodTargetExtendedResources added in v1.1.0

func GetPodTargetExtendedResources(pod *corev1.Pod, resourceNames ...corev1.ResourceName) *apiext.ExtendedResourceSpec

GetPodTargetExtendedResources gets the resource requirements of a pod with given extended resources. It returns nil if pod specifies no extended resource.

func IsIn added in v1.3.0

func IsIn(arr []string, val string) bool

func IsNodeAddressTypeSupported added in v0.4.1

func IsNodeAddressTypeSupported(addrType corev1.NodeAddressType) bool

IsNodeAddressTypeSupported determine whether addrType is a supported type.

func IsPodCPUBurstable added in v1.0.0

func IsPodCPUBurstable(pod *corev1.Pod) bool

IsPodCPUBurstable checks if cpu burst is allowed for the pod.

func IsPodCfsQuotaNeedUnset added in v1.0.0

func IsPodCfsQuotaNeedUnset(annotations map[string]string) (bool, error)

IsPodCfsQuotaNeedUnset checks if the pod-level and container-level cfs_quota should be unset to avoid unnecessary throttles. https://github.com/koordinator-sh/koordinator/issues/489

func IsPodTerminated added in v0.4.0

func IsPodTerminated(pod *corev1.Pod) bool

func IsResourceDiff

func IsResourceDiff(old, new corev1.ResourceList, resourceName corev1.ResourceName, diffThreshold float64) bool

IsResourceDiff returns whether the new resource has big enough difference with the old one or not

func IsResourceListEqualValue added in v1.3.0

func IsResourceListEqualValue(a, b corev1.ResourceList) bool

IsResourceListEqualValue checks if the two resource lists are numerically equivalent. NOTE: Resource name with a zero value will be ignored in comparison. e.g. a = {"cpu": "10", "memory": "0"}, b = {"cpu": "10"} => true

func MaxFloat64 added in v1.3.0

func MaxFloat64(i, j float64) float64

func MaxInt64 added in v0.3.0

func MaxInt64(i, j int64) int64

func MergeCfg added in v0.2.0

func MergeCfg(old, new interface{}) (interface{}, error)

MergeCfg returns a merged interface. Value in new will override old's when both fields exist. It will throw an error if:

  1. either of the inputs was nil;
  2. inputs were not a pointer of the same json struct.

func MinFloat64 added in v1.3.0

func MinFloat64(i, j float64) float64

func MinInt64 added in v0.3.0

func MinInt64(i, j int64) int64

func MinResourceList added in v1.3.0

MinResourceList returns the result of Min(a, b) for each named resource, corresponding to the quotav1.Max(). It should be semantically equivalent to the result of `quotav1.Subtract(quotav1.Add(a, b), quotav1.Max(a, b))`.


a = {"cpu": "10", "memory": "20Gi"}, b = {"cpu": "6", "memory": "24Gi", "nvidia.com/gpu": "2"}
=> {"cpu": "6", "memory": "20Gi"}

func MultiplyMilliQuant

func MultiplyMilliQuant(quant resource.Quantity, factor float64) resource.Quantity

MultiplyMilliQuant scales quantity by factor

func MultiplyQuant

func MultiplyQuant(quant resource.Quantity, factor float64) resource.Quantity

MultiplyQuant scales quantity by factor

func NewZeroResourceList

func NewZeroResourceList() corev1.ResourceList

func ParseContainerId added in v0.2.0

func ParseContainerId(data string) (cType, cID string, err error)

func PatchPod added in v0.7.0

func PatchPod(ctx context.Context, clientset clientset.Interface, oldPod, newPod *corev1.Pod) (*corev1.Pod, error)

func PatchReservation added in v0.7.0

func PatchReservation(ctx context.Context, clientset koordinatorclientset.Interface, oldReservation, newReservation *schedulingv1alpha1.Reservation) (*schedulingv1alpha1.Reservation, error)

func QuantityPtr added in v1.1.1

func QuantityPtr(q resource.Quantity) *resource.Quantity

func RemoveHostPorts added in v1.3.0

func RemoveHostPorts(ports framework.HostPortInfo, r framework.HostPortInfo)

func RequestedHostPorts added in v1.3.0

func RequestedHostPorts(pod *corev1.Pod) framework.HostPortInfo

func ResetHostPorts added in v1.3.0

func ResetHostPorts(pod *corev1.Pod, ports framework.HostPortInfo)

func RetryOnConflictOrTooManyRequests added in v0.7.0

func RetryOnConflictOrTooManyRequests(fn func() error) error

func RunFeature added in v0.2.0

func RunFeature(moduleFunc func(), featureDependency []featuregate.Feature, interval int, stopCh <-chan struct{}) bool

RunFeature runs moduleFunc only if interval > 0 AND at least one feature dependency is enabled

func RunFeatureWithInit added in v0.2.0

func RunFeatureWithInit(moduleInit func() error, moduleFunc func(), featureDependency []featuregate.Feature, interval int, stopCh <-chan struct{}) bool

RunFeatureWithInit runs moduleFunc only if interval > 0 , at least one feature dependency is enabled and moduleInit function returns nil

func SupportEviction added in v1.3.0

func SupportEviction(client kubernetes.Interface) (string, error)

func TrimNodeAllocatableByNodeReservation added in v1.3.0

func TrimNodeAllocatableByNodeReservation(node *corev1.Node) (trimmedAllocatable corev1.ResourceList, trimmed bool)


This section is empty.

Jump to

Keyboard shortcuts

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