ZBLOG

设置pod不调度到某个node

要设置 Pod 不调度到某个 Node,可以通过 Kubernetes 的 nodeSelector 和 taints & tolerations 机制实现。

方法一:使用 nodeSelector

  1. 在要排除的 Node 上设置一个 label,例如 node-role=exclude
  2. 在 Pod 的 yaml 文件中添加以下内容:
nodeSelector:
  node-role: "not-exclude"

这样,在调度 Pod 时,Kubernetes 就会查找没有 node-role=exclude 标签的节点进行调度。

方法二:使用 taints & tolerations

  1. 在要排除的 Node 上设置一个 taint:
kubectl taint nodes <node-name> key=value:taint-effect

其中 <node-name> 是节点名称,key=value 是自定义的键值对,taint-effect 可以是 NoSchedule、NoExecute 或 PreferNoSchedule。例如:

kubectl taint nodes node-1 special=true:NoSchedule

表示在 node-1 节点上设置一个特殊标记(键值对为 special=true),并禁止在该节点上调度新的 Pod。

  1. 在 Pod 的 yaml 文件中添加 toleration:
tolerations:
- key: "special"
  operator: "Equal"
  value: "true"
  effect: "NoSchedule"

这样,在调度 Pod 时,Kubernetes 就会检查该 Pod 是否有与 Node 上的 taint 匹配的 toleration。如果匹配,则允许在该 Node 上调度该 Pod。

本站部分文章来源于网络,版权归原作者所有,如有侵权请联系站长删除。
转载请注明出处:https://golang.0voice.com/?id=3839

分享:
扫描分享到社交APP
上一篇
下一篇
发表列表
游客 游客
此处应有掌声~
评论列表

还没有评论,快来说点什么吧~

联系我们

在线咨询: 点击这里给我发消息

微信号:3007537140

上班时间: 10:30-22:30

关注我们
x

注册

已经有帐号?