Taints and Tolerations
来源:互联网 发布:封面制作软件ios 编辑:程序博客网 时间:2024/06/02 02:15
node affnity是一种pod选择node的资源(表述倾向或者强制约束),taint是相反的,taint和toleration协同工作从而防止pod调度到不恰当的节点名上面,一个或多个taint可以被应用到node上面,标记了node不接收那些不能容忍这些污点的pod,耐受应用于pod,允许pods调度到有污点的节点上面
使用 kubectl命令给node添加污点
kubectl taint nodes node1 key=value:NoSchedule
给node1添加了一个taint,taint包含键 key 值 value,和一个taint effect noschedule,这意味着pod不能调度到这个节点上面除非pod包含一个合适的toleraction,指定tolerations在pod 的podspec字段,下面的两个tolertion都匹配了上面创建的taint,因此包含下面任意toleraction的pod都可以被调度到node1
tolerations:
- key: "key"
operator: "Equal"
value: "value"
effect: "NoSchedule"
tolerations:
- key: "key"
operator: "Exists"
effect: "NoSchedule"
一个toleraction 匹配一个raint如果keys相同并且effects也是一样的,operator 为Exists(在这种情况不能指定value),当operator为Equal时value必须指定,在operator默认为equal
注:
一个空的key并且operator为exists 匹配所有的key和value effects意味着容忍所有
tolerations:
- operator: "Exists"
空的effect意味匹配所有具有该key的effect
tolerations:
- key: "key"
operator: "Exists"
这上面的例子使用 noschedule的effect类型,另外你可以使用 prefernoscheduler ,这是一种倾向火软限制版本的noschdule,系统将尽可能把pod放在不能容忍的节点上,但是非必要
第三种effect noexecute 稍后介绍
你可以将多种taint添加到同一个node上面,也可以将多个roleraction在相同的pod,k8s处理多个taints和toleraction的方式类似一个filter,从所有的taints开始,然后忽略已经匹配到的toleraction,剩余没有被忽略的taint将被标明,特殊情况:
如果包含一个未被忽略的taint effect为noschedule,该pod将不会被调度到这个pod
如果包含noscheduler也包含prefernoscheduler k8s将试图将pod调度到该node
如果未被忽略的taint包含noexecute 该pod将被驱逐
例如
kubectl taint nodes node1 key1=value1:NoSchedule
kubectl taint nodes node1 key1=value1:NoExecute
kubectl taint nodes node1 key2=value2:NoSchedule
创建一个包含两个roleractions的pod
tolerations:
- key: "key1"
operator: "Equal"
value: "value1"
effect: "NoSchedule"
- key: "key1"
operator: "Equal"
value: "value1"
effect: "NoExecute
在这个例子中pod无法调度到node上面因为没有roleraction匹配第三个taint,任何包含tolerate 该taint的pod将不会被驱逐,一个noexecute的effect可以设置一个时间参数,
tolerations:
- key: "key1"
operator: "Equal"
value: "value1"
effect: "NoExecute"
tolerationSeconds: 3600
意味着如果一个pod运行在一个匹配的污点node上面,这个pod奖杯保持3600秒,然后被驱逐,如果这个taint被移除在驱逐之前,这个pod不会被驱逐
用例说明:
1.专用节点
2.节点包含特殊硬件
3.基于污点的驱逐 每个节点可以配置驱逐行为当节点出问题的时候
前面我们提到的noexecute taint作用,从而影响pods已经运行在节点如下
1.pod没有配置tolerate奖杯立即驱逐
使用 kubectl命令给node添加污点
kubectl taint nodes node1 key=value:NoSchedule
给node1添加了一个taint,taint包含键 key 值 value,和一个taint effect noschedule,这意味着pod不能调度到这个节点上面除非pod包含一个合适的toleraction,指定tolerations在pod 的podspec字段,下面的两个tolertion都匹配了上面创建的taint,因此包含下面任意toleraction的pod都可以被调度到node1
tolerations:
- key: "key"
operator: "Equal"
value: "value"
effect: "NoSchedule"
tolerations:
- key: "key"
operator: "Exists"
effect: "NoSchedule"
一个toleraction 匹配一个raint如果keys相同并且effects也是一样的,operator 为Exists(在这种情况不能指定value),当operator为Equal时value必须指定,在operator默认为equal
注:
一个空的key并且operator为exists 匹配所有的key和value effects意味着容忍所有
tolerations:
- operator: "Exists"
空的effect意味匹配所有具有该key的effect
tolerations:
- key: "key"
operator: "Exists"
这上面的例子使用 noschedule的effect类型,另外你可以使用 prefernoscheduler ,这是一种倾向火软限制版本的noschdule,系统将尽可能把pod放在不能容忍的节点上,但是非必要
第三种effect noexecute 稍后介绍
你可以将多种taint添加到同一个node上面,也可以将多个roleraction在相同的pod,k8s处理多个taints和toleraction的方式类似一个filter,从所有的taints开始,然后忽略已经匹配到的toleraction,剩余没有被忽略的taint将被标明,特殊情况:
如果包含一个未被忽略的taint effect为noschedule,该pod将不会被调度到这个pod
如果包含noscheduler也包含prefernoscheduler k8s将试图将pod调度到该node
如果未被忽略的taint包含noexecute 该pod将被驱逐
例如
kubectl taint nodes node1 key1=value1:NoSchedule
kubectl taint nodes node1 key1=value1:NoExecute
kubectl taint nodes node1 key2=value2:NoSchedule
创建一个包含两个roleractions的pod
tolerations:
- key: "key1"
operator: "Equal"
value: "value1"
effect: "NoSchedule"
- key: "key1"
operator: "Equal"
value: "value1"
effect: "NoExecute
在这个例子中pod无法调度到node上面因为没有roleraction匹配第三个taint,任何包含tolerate 该taint的pod将不会被驱逐,一个noexecute的effect可以设置一个时间参数,
tolerations:
- key: "key1"
operator: "Equal"
value: "value1"
effect: "NoExecute"
tolerationSeconds: 3600
意味着如果一个pod运行在一个匹配的污点node上面,这个pod奖杯保持3600秒,然后被驱逐,如果这个taint被移除在驱逐之前,这个pod不会被驱逐
用例说明:
1.专用节点
2.节点包含特殊硬件
3.基于污点的驱逐 每个节点可以配置驱逐行为当节点出问题的时候
前面我们提到的noexecute taint作用,从而影响pods已经运行在节点如下
1.pod没有配置tolerate奖杯立即驱逐
2.包含驱逐时间的将会到驱逐时间后驱逐
kubeadm 启动的master包含
taints:
- effect: NoSchedule
key: node-role.kubernetes.io/master
timeAdded: null
kubectl taint nodes --all node-role.kubernetes.io/master-
手动添加
kubectl taint node node1 node-role.kubernetes.io/master="":NoSchedule
阅读全文
0 0
- Taints and Tolerations
- 深入kubernetes调度之Taints和Tolerations
- module license 'unspecified' taints kernel
- module license 'unspecified' taints kernel.
- To Be More Attractive? Zap The Tolerations!
- hello: module license 'unspecified' taints kernel.
- module license 'unspecified' taints kernel解决
- 使用DaemonSet+Taint/Tolerations+NodeSelector部署Nginx Ingress Controller
- insmod时出现module license 'unspecified' taints kernel
- Linux驱动开发错误:module license 'unspecified' taints kernel.
- insmod出现loading out-of-tree module taints kernel
- hello: module license 'unspecified' taints kernel.错误--编写内核模块意见
- " and '
- $* and $@
- AND
- AND
- & and &&
- ""and ‘’
- LeetCode 633 Sum of Square Numbers
- poj2063 Investment(完全背包)
- hdu6201transaction transaction transaction(最长路spfa vector模板)
- 0911 Oracle基本概念
- 3Layer
- Taints and Tolerations
- 电子之电容测试标准
- eclipse配置生成.h和.so文件过程
- 剑指offer——42.和为sum的两个数字
- 勤智OneCenter:视频监控系统运维解决方案
- linux crontab
- angular内置服务interval和timeout
- Exception Handling in Java
- 谷歌又新增了两个意想不到的功能