1
0
mirror of https://github.com/kubernetes-sigs/descheduler.git synced 2026-01-26 05:14:13 +01:00

support extended resources in lownodeutilization

This commit is contained in:
ZongqiangZhang
2021-04-02 21:37:51 +08:00
parent 9ebc909c7f
commit 81b816d4a4
4 changed files with 380 additions and 97 deletions

View File

@@ -173,3 +173,14 @@ func SetPodPriority(pod *v1.Pod, priority int32) {
func SetNodeUnschedulable(node *v1.Node) {
node.Spec.Unschedulable = true
}
// SetPodExtendedResourceRequest sets the given pod's extended resources
func SetPodExtendedResourceRequest(pod *v1.Pod, resourceName v1.ResourceName, requestQuantity int64) {
pod.Spec.Containers[0].Resources.Requests[resourceName] = *resource.NewQuantity(requestQuantity, resource.DecimalSI)
}
// SetNodeExtendedResouces sets the given node's extended resources
func SetNodeExtendedResource(node *v1.Node, resourceName v1.ResourceName, requestQuantity int64) {
node.Status.Capacity[resourceName] = *resource.NewQuantity(requestQuantity, resource.DecimalSI)
node.Status.Allocatable[resourceName] = *resource.NewQuantity(requestQuantity, resource.DecimalSI)
}