当一个集群中有多个节点有足够多的资源来运行容器时,Kubernetes会给每个节点打分,然后选出一个得分最高的结点部署容器。本文讨论与资源(内存和CPU)相关的调度器打分算法和配置。
1. 算法
Kubernetes调度器有三个算法与资源相关。第一个是least_requested算法。它的核心思想是把尽可能地降低每个节点的资源利用率,把容器分散到尽可能多的节点上去。它的打分算法如下:
// Theunused capacity is calculated on a scale of 0-10
// 0being the lowest priority and 10 being the highest.
// Themore unused resources the higher the score is.
func calculateUnusedScore(requested int64, capacity int64, node string) int64 {
if capacity == 0 {
return 0
}
if requested > capacity {
glog.V(10).Infof("Combinedrequested resources %d from existing pods exceeds capacity %d on node %s",
requested, capacity