上一节学习的Affinity是在pod创建的时候设置的,但是随着pod的数目越来越多,更有效率的方式应该是在node端设置一些记号,pod默认就不会调度在这个node上,而只有一些经过特殊设置的pod才可以在该node调度。这就是这一节要学习的Taint和Toleration。
我是T型人小付,一位坚持终身学习的互联网从业者。喜欢我的博客欢迎在csdn上关注我,如果有问题欢迎在底下的评论区交流,谢谢。
文章目录
Taint
Taint,污点,是在node上的一个设置,格式如下
key=value:effect
其中value可以为空,effect是该污点所对应的对pod的动作,可以为如下的一种
- NoSchedule - 表示k8s将不会将pod调度到具有该污点的node
- PreferNoSchedule - 表示k8s尽量避免将pod调度到具有该污点的node
- NoExecute - 表示k8s将不会将pod调度到具有该污点的node,并且该node上已存在的pod还会被驱逐(如果是控制器创建的pod会在别的node被重新创建)
污点设置和删除命令举例如下
# Update node 'foo' with a taint with key 'dedicated' and value 'special-user' and effect 'NoSchedule'.
# If a taint with that key and effect already exists, its value is replaced as specified.
kubectl taint nodes foo dedicated=special-user:NoSchedule
# Remove from node 'foo' the taint with key 'dedicated' and effect 'NoSchedule' if one exists.
kubectl taint nodes foo dedicated:NoSchedule-
# Remove from node 'foo' all the taints with key 'dedicated'
kubectl taint nodes foo dedicated-
# Add a taint with key 'dedicated' on nodes having label mylab