utils

package
v0.29.0 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2023 License: Apache-2.0 Imports: 14 Imported by: 2

Documentation

Index

Constants

View Source
const SystemCriticalPriority = 2 * int32(1000000000)

Variables

This section is empty.

Functions

func GetNamespacesFromPodAffinityTerm added in v0.10.0

func GetNamespacesFromPodAffinityTerm(pod *v1.Pod, podAffinityTerm *v1.PodAffinityTerm) sets.Set[string]

GetNamespacesFromPodAffinityTerm returns a set of names according to the namespaces indicated in podAffinityTerm. If namespaces is empty it considers the given pod's namespace.

func GetNodeWeightGivenPodPreferredAffinity added in v0.28.0

func GetNodeWeightGivenPodPreferredAffinity(pod *v1.Pod, node *v1.Node) (int32, error)

Returns the weight that the pod gives to a node by analyzing the soft node affinity of that pod (nodeAffinity.preferredDuringSchedulingIgnoredDuringExecution)

func GetPodQOS added in v0.10.0

func GetPodQOS(pod *v1.Pod) v1.PodQOSClass

GetPodQOS returns the QoS class of a pod. A pod is besteffort if none of its containers have specified any requests or limits. A pod is guaranteed only when requests and limits are specified for all the containers and they are equal. A pod is burstable if limits and requests do not match across all containers.

func GetPodSource added in v0.10.0

func GetPodSource(pod *v1.Pod) (string, error)

GetPodSource returns the source of the pod based on the annotation.

func GetPriorityFromPriorityClass added in v0.19.0

func GetPriorityFromPriorityClass(ctx context.Context, client clientset.Interface, name string) (int32, error)

GetPriorityFromPriorityClass gets priority from the given priority class. If no priority class is provided, it will return SystemCriticalPriority by default.

func GetPriorityValueFromPriorityThreshold added in v0.25.0

func GetPriorityValueFromPriorityThreshold(ctx context.Context, client clientset.Interface, priorityThreshold *api.PriorityThreshold) (priority int32, err error)

GetPriorityValueFromPriorityThreshold gets priority from the given PriorityThreshold. It will return SystemCriticalPriority by default.

func GetRecorderAndBroadcaster added in v0.25.0

func GetRecorderAndBroadcaster(ctx context.Context, clientset clientset.Interface) (events.EventBroadcasterAdapter, events.EventRecorder)

func GetResourceRequest added in v0.10.0

func GetResourceRequest(pod *v1.Pod, resource v1.ResourceName) int64

GetResourceRequest finds and returns the request value for a specific resource.

func GetResourceRequestQuantity added in v0.10.0

func GetResourceRequestQuantity(pod *v1.Pod, resourceName v1.ResourceName) resource.Quantity

GetResourceRequestQuantity finds and returns the request quantity for a specific resource.

func IsCriticalPriorityPod added in v0.21.0

func IsCriticalPriorityPod(pod *v1.Pod) bool

IsCriticalPriorityPod returns true if the pod has critical priority.

func IsDaemonsetPod added in v0.21.0

func IsDaemonsetPod(ownerRefList []metav1.OwnerReference) bool

IsDaemonsetPod returns true if the pod is a IsDaemonsetPod.

func IsMirrorPod added in v0.10.0

func IsMirrorPod(pod *v1.Pod) bool

IsMirrorPod returns true if the pod is a Mirror Pod.

func IsPodTerminating added in v0.23.0

func IsPodTerminating(pod *v1.Pod) bool

IsPodTerminating returns true if the pod DeletionTimestamp is set.

func IsPodWithLocalStorage added in v0.21.0

func IsPodWithLocalStorage(pod *v1.Pod) bool

IsPodWithLocalStorage returns true if the pod has local storage.

func IsPodWithPVC added in v0.21.0

func IsPodWithPVC(pod *v1.Pod) bool

IsPodWithPVC returns true if the pod has claimed a persistent volume.

func IsStaticPod added in v0.10.0

func IsStaticPod(pod *v1.Pod) bool

IsStaticPod returns true if the pod is a static pod.

func NodeSelectorsEqual added in v0.21.0

func NodeSelectorsEqual(n1, n2 *v1.NodeSelector) bool

func PodHasNodeAffinity added in v0.28.0

func PodHasNodeAffinity(pod *v1.Pod, nodeAffinityType NodeAffinityType) bool

PodHasNodeAffinity returns true if the pod has a node affinity of type `nodeAffinityType` defined. The nodeAffinityType param can take this two values: "requiredDuringSchedulingIgnoredDuringExecution" or "requiredDuringSchedulingIgnoredDuringExecution"

func PodMatchNodeSelector

func PodMatchNodeSelector(pod *v1.Pod, node *v1.Node) (bool, error)

PodMatchNodeSelector checks if a pod node selector matches the node label.

func PodMatchesTermsNamespaceAndSelector added in v0.10.0

func PodMatchesTermsNamespaceAndSelector(pod *v1.Pod, namespaces sets.Set[string], selector labels.Selector) bool

PodMatchesTermsNamespaceAndSelector returns true if the given <pod> matches the namespace and selector defined by <affinityPod>`s <term>.

func PodRequestsAndLimits added in v0.10.0

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 PodToleratesTaints added in v0.18.0

func PodToleratesTaints(pod *v1.Pod, taintsOfNodes map[string][]v1.Taint) bool

PodToleratesTaints returns true if a pod tolerates one node's taints

func TolerationsEqual added in v0.21.0

func TolerationsEqual(t1, t2 []v1.Toleration) bool

func TolerationsTolerateTaint added in v0.18.0

func TolerationsTolerateTaint(tolerations []v1.Toleration, taint *v1.Taint) bool

TolerationsTolerateTaint checks if taint is tolerated by any of the tolerations.

func TolerationsTolerateTaintsWithFilter added in v0.18.0

func TolerationsTolerateTaintsWithFilter(tolerations []v1.Toleration, taints []v1.Taint, applyFilter taintsFilterFunc) bool

TolerationsTolerateTaintsWithFilter checks if given tolerations tolerates all the taints that apply to the filter in given taint list.

Types

type NodeAffinityType added in v0.28.0

type NodeAffinityType string
const (
	RequiredDuringSchedulingIgnoredDuringExecution  NodeAffinityType = "requiredDuringSchedulingIgnoredDuringExecution"
	PreferredDuringSchedulingIgnoredDuringExecution NodeAffinityType = "preferredDuringSchedulingIgnoredDuringExecution"
)

type QOSList added in v0.10.0

type QOSList map[v1.ResourceName]v1.PodQOSClass

QOSList is a set of (resource name, QoS class) pairs.

Jump to

Keyboard shortcuts

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