kubernetes 了解节点到分数百分比默认行为

yjghlzjz  于 2022-11-02  发布在  Kubernetes
关注(0)|答案(1)|浏览(337)

Kubernetes Scheduler在尝试调度Pod时可能会使用集群节点的子集,具体取决于集群中的节点数和调度程序Configuration
我想知道默认行为是什么,因为kube-scheduler-config API文档并不清楚:

节点得分百分比[必需] int 32

PercentageOfNodesToScore是所有节点的百分比,一旦找到可执行机组的节点,排程器便会停止搜寻丛集中更多的可行节点。这有助于改善排程器的效能。无论此旗标的值为何,排程器一律会尝试寻找至少“minFeasibleNodesToFind”个可行节点。范例:如果集群大小为500个节点,并且此标志的值为30,则调度程序在找到150个可行节点后将停止进一步查找可行节点。当值为0时,将对节点的默认百分比(基于集群大小的5%-50%)进行评分。

6ss1mwsb

6ss1mwsb1#

当KubeSchedulerConfiguration节点得分百分比设置为0时,将启用kubernetes 1.25中得调度程序默认行为.
默认行为是扫描50%的节点,该百分比减去集群中的节点数除以125(例如:2500个节点/125=20 =〉50% - 20个点=〉扫描30%的节点)。要扫描的最小节点为总数的5%或100个节点。
要完全理解调度程序的行为,请深入了解Kubernetes的源代码。

const (
    // SchedulerError is the reason recorded for events when an error occurs during scheduling a pod.
    SchedulerError = "SchedulerError"
    // Percentage of plugin metrics to be sampled.
    pluginMetricsSamplePercent = 10
    // minFeasibleNodesToFind is the minimum number of nodes that would be scored
    // in each scheduling cycle. This is a semi-arbitrary value to ensure that a
    // certain minimum of nodes are checked for feasibility. This in turn helps
    // ensure a minimum level of spreading.
    minFeasibleNodesToFind = 100
    // minFeasibleNodesPercentageToFind is the minimum percentage of nodes that
    // would be scored in each scheduling cycle. This is a semi-arbitrary value
    // to ensure that a certain minimum of nodes are checked for feasibility.
    // This in turn helps ensure a minimum level of spreading.
    minFeasibleNodesPercentageToFind = 5
)

// == trucated == //

// numFeasibleNodesToFind returns the number of feasible nodes that once found, the scheduler stops
// its search for more feasible nodes.
func (sched *Scheduler) numFeasibleNodesToFind(numAllNodes int32) (numNodes int32) {
    if numAllNodes < minFeasibleNodesToFind || sched.percentageOfNodesToScore >= 100 {
        return numAllNodes
    }

    adaptivePercentage := sched.percentageOfNodesToScore
    if adaptivePercentage <= 0 {
        basePercentageOfNodesToScore := int32(50)
        adaptivePercentage = basePercentageOfNodesToScore - numAllNodes/125
        if adaptivePercentage < minFeasibleNodesPercentageToFind {
            adaptivePercentage = minFeasibleNodesPercentageToFind
        }
    }

    numNodes = numAllNodes * adaptivePercentage / 100
    if numNodes < minFeasibleNodesToFind {
        return minFeasibleNodesToFind
    }

    return numNodes
}

相关问题