CKA [Installation] – Taints 和 Tolerations的讲解

官方文档:https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/

🚩 一、Taints & Tolerations 是什么?

💡 定义

  • Taint(污点):是加在 Node 上 的标记,用来表示「这个节点不希望普通的 Pod 被调度上来」。
  • Toleration(容忍):是加在 Pod 上 的标记,用来表示「这个 Pod 可以容忍某些污点的 Node」。

🧠 简单讲:

Taint 是节点说:「我不欢迎任何 Pod 来,除非你能容忍我」
Toleration 是 Pod 说:「我能接受这个节点的污点,所以我可以去」

比如以上的这个例子,WorkerNode1 使用了taint,你可以把taint想象成一个防护罩,导致了Pod-1无法deploy进去,所以Pod-1只好deploy进WorkerNode2

如果Pod-1依然想要deploy进WorkerNode1的话,那么Pod-1需要带上special-pass , 而这个special pass就是toleration。

以下的命令行是查看当下的nodes

kubectl get nodes
kubectl describe nodes ip-52-0-15-131

使用这个命令行可以查看 nodes的详细信息,我们可以查看到这个control-plane的taint记录

⚙️ 基本格式

Node 添加污点:

kubectl taint nodes node1 key=value:NoSchedule

意思是:给节点 node1 添加一个键值为 key=value 的污点,并设置效果 NoSchedule

如果想要去除taint的话,可以在尾端添加 symbol “-“

kubectl taint nodes ip-52-0-15-131 dedicated=prod:NoSchedule-

Loading

Facebook评论