1
0
mirror of https://github.com/kubernetes-sigs/descheduler.git synced 2026-01-28 06:29:29 +01:00

check for taints on low nodes and honor them

This commit is contained in:
Joel Whittaker-Smith
2019-09-12 12:31:15 +02:00
parent 137b9b72e7
commit 4757132452
4 changed files with 252 additions and 8 deletions

View File

@@ -2,10 +2,12 @@ package utils
import (
"fmt"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
utilfeature "k8s.io/apiserver/pkg/util/feature"
"k8s.io/component-base/featuregate"
"k8s.io/klog"
)
const (
@@ -179,3 +181,15 @@ func maxResourceList(list, new v1.ResourceList) {
}
}
}
// PodToleratesTaints returns true if a pod tolerates one node's taints
func PodToleratesTaints(pod *v1.Pod, taintsOfNodes map[string][]v1.Taint) bool {
for nodeName, taintsForNode := range taintsOfNodes {
if len(pod.Spec.Tolerations) >= len(taintsForNode) && TolerationsTolerateTaintsWithFilter(pod.Spec.Tolerations, taintsForNode, nil) {
return true
}
klog.V(5).Infof("pod: %#v doesn't tolerate node %s's taints", pod.Name, nodeName)
}
return false
}