k8s调度器、预选策略、优选函数

节点选择过程

  • 节点预选过程(predicate)
  • 优选过程(priority)
  • 选定节点(select)

调度器

预选策略

  • CheckNodeCondition:检查节点是否正常

  • GeneralPredicates:

    • Hostname:检查pod对象是否定义了pod.spec.host
    • PodFitsHostPorts:检查pod对象的 pod.spec.containers.ports.hostport
    • MatchNodeSelector:检查pod.spec.nodeSelector
    • PodFitsResources:检查pod对资源的需求能否被资源满足
  • (默认不启用)NoDiskConflict:检查pod依赖的存储卷 是否能满足需求

  • PodToleratesNodeTains: 检查污点与容忍。pod.spec.tolerations

  • (默认不启用)PodToleratesNodenoExcuteTains:驱离污点

  • (默认不启用)checkNodeLabelPresence:检查标签的存在性

  • (默认不启用)checkServiceAffinity:将 同一个service 下的pod 尽可能放在一个Node下

  • MaxEBSVolumeCount

  • MaxGCEPDVolumeCount

  • MaxAzureDiskVolumeCount

  • CheckVolumeBinding:

  • NoVolumeZoneConflict:

  • CheckNodeMemoryPressure: 检查内存压力

  • CheckNodePIDPressure:检查进程压力

  • CheckNodeDiskPressure

  • MatchInterPodAffitnity: pod间的亲和性

优选函数

https://github.com/kubernetes/kubernetes/tree/master/pkg/scheduler/algorithm/priorities

  • LeastRequested:按照资源使用量得分
  • BalancedResourceAllocation : CPU和内存资源占用率相近的胜出。平衡资源使用情况
  • NodePreferAvoidPods:根据节点的注解信息 "scheduler.aplpha.kubernetes.io/preferAvoidPods" Node 倾向于不
  • TainToleration:将pod对象的spec.tolerations 与node的Tain进行匹配度检查,匹配的条目越多,得分越低。
  • SelectorSpreading:尽可能的将相同标签选择器的pod 分散在不同的node上。
  • InterPodAffinity:亲和性匹配项
  • nodeAffinity:节点亲和性
  • (默认不启用)MostRequested:服务器空闲度越低,越优先
  • (默认不启用)NodeLabel:根据node标签评分
  • (默认不启用)imageLocality:节点上是否有需求的镜像,根据镜像的体积大小之和计算

根据预选与优选 影响pod 的节点选择,主要可以通过污点、pod亲和性、node亲和性。

高级调度设置机制

  • 节点选择器/节点亲和调度:nodeSelector, nodeName, nodeAffinity

node选择器/node亲和调度

  • nod.spec.nodeName : 根据node 名称选择
  • nod.spec.nodeSelector:根据node 的标签进行选择

强约束,条件不满足则pedding

  • pod.spec.affinity.nodeAffinity

    • preferredDuringSchedulingIgnoredDuringExecution 非强制性 ,多条件权重
    • requiredDuringSchedulingIgnoredDuringExecution 强制性

pod亲和性

  • pod.spec.affinity.podAffinity

    • preferredDuringSchedulingIgnoredDuringExecution 非强制性
    • requiredDuringSchedulingIgnoredDuringExecution 强制性
      • labelSelector
      • namespace
      • topologykey 必须的 affinity、anti-affinity

污点调度 Taints 与 Tolerations

Taints 给予node定义,那些pod可以执行

**pod 使用 Tolerations指定容忍的污点 **

node.spec.taints

FIELDS:
effect <string> -required-
Required. The effect of the taint on pods that do not tolerate the taint.
Valid effects are NoSchedule, PreferNoSchedule and NoExecute. key <string> -required-
Required. The taint key to be applied to a node. timeAdded <string>
TimeAdded represents the time at which the taint was added. It is only
written for NoExecute taints. value <string>
Required. The taint value corresponding to the taint key.

effect: 用于定义排斥的行为:

  • NoSchedule :仅仅影响调度过程,对已经存在的pod不产生影响。
  • PreferNoSchedule:最好不调度,但是可容忍。
  • NoExecute:既影响调度过程,也影响存在的pod对象。驱逐。

管理节点污点

 kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N [options]

pod.spec.tolerations

可以让pod 容忍 node 上的污点。

FIELDS:
effect <string>
Effect indicates the taint effect to match. Empty means match all taint
effects. When specified, allowed values are NoSchedule, PreferNoSchedule
and NoExecute. key <string>
Key is the taint key that the toleration applies to. Empty means match all
taint keys. If the key is empty, operator must be Exists; this combination
means to match all values and all keys. operator <string>
Operator represents a key's relationship to the value. Valid operators are
Exists and Equal. Defaults to Equal. Exists is equivalent to wildcard for
value, so that a pod can tolerate all taints of a particular category. tolerationSeconds <integer>
TolerationSeconds represents the period of time the toleration (which must
be of effect NoExecute, otherwise this field is ignored) tolerates the
taint. By default, it is not set, which means tolerate the taint forever
(do not evict). Zero and negative values will be treated as 0 (evict
immediately) by the system. value <string>
Value is the taint value the toleration matches to. If the operator is
Exists, the value should be empty, otherwise just a regular string.

05-k8s调度器、预选策略、优选函数的更多相关文章

  1. k8s调度的预选策略及优选函数

    scheduler调度过程:    Predicate(预选)-->Priority(优选)-->Select(选定)调度方式:    1.节点亲和性调度(NodeAffinity)使用n ...

  2. 7.k8s.调度器scheduler 亲和性、污点

    #k8s. 调度器scheduler 亲和性.污点 默认调度过程:预选 Predicates (过滤节点) --> 优选 Priorities(优先级排序) --> 优先级最高节点 实际使 ...

  3. golang中GPM模型原理与调度器设计策略

    一.GMP模型原理first: 1. 全局队列:存放待运行的G2. P的本地队列:同全局队列类似,存放待运行的G,存储的数量有限:256个,当创建新的G'时,G'优先加入到P的本地队列,如果队列已满, ...

  4. K8S 调度器,预选策略,优选函数

    Kubernetes Scheduler 提供的调度流程分三步: 预选策略(predicate) 遍历nodelist,选择出符合要求的候选节点,Kubernetes内置了多种预选规则供用户选择. 优 ...

  5. k8s调度器、预选策略及调度方式

    一.k8s调度流程 1.(预选)先排除完全不符合pod运行要求的节点2.(优先)根据一系列算法,算出node的得分,最高没有相同的,就直接选择3.上一步有相同的话,就随机选一个 二.调度方式 1.no ...

  6. 图解kubernetes调度器预选设计实现学习

    Scheduler中在进行node选举的时候会首先进行一轮预选流程,即从当前集群中选择一批node节点,本文主要分析k8s在预选流程上一些优秀的筛选设计思想,欢迎大佬们指正 1. 基础设计 1.1 预 ...

  7. k8s调度器kube-scheduler

    kube-scheduler简介 调度是容器编排的重要环节,需要经过严格的监控和控制,现实生产通常对调度有各类限制,譬如某些服务必须在业务独享的机器上运行,或者从灾备的角度考虑尽量把服务调度到不同机器 ...

  8. 泡面不好吃,我用了这篇k8s调度器,征服了他

    1.1 调度器简介 来个小刘一起 装逼吧 ,今天我们来学习 K8的调度器 Scheduler是 Kubernetes的调度器,主要的任务是把定义的 pod分配到集群的节点上,需要考虑以下问题: 公平: ...

  9. k8s调度器介绍(调度框架版本)

    从一个pod的创建开始 由kubectl解析创建pod的yaml,发送创建pod请求到APIServer. APIServer首先做权限认证,然后检查信息并把数据存储到ETCD里,创建deployme ...

  10. golang中goroutine协程调度器设计策略

    goroutine与线程 /* goroutine与线程1. 可增长的栈os线程一般都有固定的栈内存,通常为2MB,一个goroutine的在其声明周期开始时只有很小的栈(2KB),goroutine ...

随机推荐

  1. 程序代写, CS代写, 代码代写, CS编程代写, java代写, python代写, c++/c代写, R代写, 算法代写, web代写

    互联网一线工程师程序代写 微信联系 当天完成 查看大牛简介特色: 学霸代写,按时交付,保证原创,7*24在线服务,可加急.用心代写/辅导/帮助客户CS作业. 客户反馈与评价 服务质量:保证honor ...

  2. SecureCRT的安装以及破破解(内含安装包)

    1.百度网盘连接:链接:https://pan.baidu.com/s/13i8sblGthYtj2SbUTrbmsg  提取码:8cw1 2.解压前先关闭电脑防护软件,否则会杀掉破解软件的 3.压缩 ...

  3. Zookeeper详解-工作流和leader选举(三)

    一.工作流 一旦ZooKeeper集合启动,它将等待客户端连接.客户端将连接到ZooKeeper集合中的一个节点.它可以是leader或follower节点.一旦客户端被连接,节点将向特定客户端分配会 ...

  4. Python自学day-6

    一.编程范式       编程:程序员用特定的语法.数据结构和算法告诉计算机如何执行任务的过程.实现任务有很多不同的方式,根据编程方式的特点进行归纳总结出来的编程方式类别,就叫编程范式.大多数语言只支 ...

  5. Scala 学习之路(四)—— 数组Array

    一.定长数组 在Scala中,如果你需要一个长度不变的数组,可以使用Array.但需要注意以下两点: 在Scala中使用(index)而不是[index]来访问数组中的元素,因为访问元素,对于Scal ...

  6. Spark学习之路(九)—— Spark SQL 之 Structured API

    一.创建DataFrame和Dataset 1.1 创建DataFrame Spark中所有功能的入口点是SparkSession,可以使用SparkSession.builder()创建.创建后应用 ...

  7. Programming In Lua 第十章

    1,lua中的数据结构都是表来实现的.数组就是索引为数值的表. 2,矩阵就是二维数组,三角矩阵就是矩阵的一半. 3,稀疏矩阵问题: 4, 5, 6,

  8. SQL高度优化

      受同事dd之托,优化一条boss看的报表SQL.dd写复杂疑难SQL无数,如何写出优雅的SQL自有一番心得体会.能将一条7表含inner join,left join并含有关联子查询的.返回结果集 ...

  9. 设计模式-抽象工厂模式(AbstractFactory)

    抽象工厂模式是向客户端提供一个接口(FruitFactory),,使得客户端在不必指定产品的具体类型的情况下,能够创建多个产品族(NorthFruit.SouthFruit)的产品对象. 角色和职责: ...

  10. js动态生成数据的抓取

    需求:爬取https://www.xuexi.cn/f997e76a890b0e5a053c57b19f468436/018d244441062d8916dd472a4c6a0a0b.html页面中的 ...