男儿欲遂平生志,五经勤向窗前读。这篇文章主要讲述k8s-调度score算法解析相关的知识,希望能为你提供帮助。
1.Score算法1.1noderesources.BalancedAllocationName
节点cpu使用百分比和内存使用百分比越接近,说明资源使用越均衡,节点分数越高
1.18版本源码解析
1.22版本源码截图
1.2imagelocality
选择已经存在
Pod
运行所需容器镜像的节点。
检查Node是否存在Pod所需镜像:如果不存在,返回0分;如果存在,则镜像越大得分越高。
同时,如果一个pod中有两个容器镜像,如果节点上两个镜像都存在的节点分数
〉节点上只有一个镜像的分数
那么有相同镜像数量的节点的分数就是相同的
会考虑镜像在每个节点的分布情况,避免每次都选择同一个节点。
// scaledImageScore returns an adaptively scaled score for the given state of an image.
// The size of the image is used as the base score, scaled by a factor which considers how much nodes the image has "spread" to.
// This heuristic aims to mitigate the undesirable "node heating problem", i.e., pods get assigned to the same or
// a few nodes due to image locality.
源码
1.3noderesources.LeastAllocatedName
资源Requested越小的节点,即资源剩余越多的节点,分数越大
1.4nodeaffinity.Name
节点硬亲和通过filter过滤掉了
affinity:#亲和性
nodeAffinity:#node亲和性
# 硬亲和性限制
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname # 标签键名
operator: NotIn#键值运算关系 ,NotIn:label的值不在某个列表中。 表示不是node02节点就可运行
values:
- k8s-node02 # 标签键值
节点软亲和,可以写多个亲和策略
affinity:#亲和性
nodeAffinity:#node亲和性
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 1#权重,权重越大越亲和(多个软策略的情况)
preference:
matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- k8s-node03# 期望是node03
1.5nodepreferavoidpods.Name
1.6podtopologyspread.Name
有点复杂,后面补充
1.7tainttoleration.Name
spec:
tolerations:#containers同级
- key: "check"#能容忍的污点key
operator: "Equal"#Equal等于表示key=value , Exists不等于,表示当值不等于下面value正常
value: "guozige"#值
effect: "PreferNoSchedule"#effect策略
tolerationSeconds: 3600#原始的pod多久驱逐,注意只有effect: "NoExecute"才能设置,不然报错
通过filter过滤掉pod没有容忍node上污点的节点
通过score来处理effect:
"PreferNoSchedule"
#effect策略
这种污点的节点分数
参考文献??https://zhuanlan.zhihu.com/p/27754017??
??https://kubernetes.io/zh/docs/reference/scheduling/config/#scheduling-plugins??
【k8s-调度score算法解析】
推荐阅读
- Linux学习4. Linux系统基本的文件目录管理
- Linux学习3. 熟悉Linux系统基本的目录结构
- LINUX编译mate-desktop/terminal-1.24.0终端
- Linux学习11. Linux基本配置之修改IPDNS和主机名
- k8s-vpa深入剖析
- No package ‘dconf‘ found
- Linux学习9. Linux的软件包及数据源配置
- No package ‘gtksourceview-3.0‘ found/无法定位软件包 libgtksourceview-3-dev
- Linux学习8. Linux系统的文件权限管理