目录

kubectl-污点策略

创建资源时,默认会将资源分布部署在所有node节点上,如果需要在某node节点上部署更多资源或尽量不部署资源,可以用污点策略来达到需求

污点标签

  • NoSchedule 不会被调度
  • PreferNoSchedule 尽量不调度
  • NoExecute 驱逐节点(会对正在运行的容器生效)

查看污点标签

kubectl describe nodes [node节点名称]

[root@k8s-master k8s-ymls]# kubectl describe nodes k8s-master
...
Taints:             node-role.kubernetes.io/control-plane:NoSchedule
...

设置污点标签

kubectl taint node [node节点名称] key=value:NoSchedule

[root@k8s-master k8s-ymls]# kubectl taint node k8s-node1 wd=aaa:NoSchedule
[root@k8s-master k8s-ymls]# kubectl describe nodes k8s-node1
...
Taints:             wd=aaa:NoSchedule
...

删除污点标签

kubectl taint node [node节点名称] key-

[root@k8s-master k8s-ymls]# kubectl taint node k8s-node1 wd-
node/k8s-node1 untainted
[root@k8s-master k8s-ymls]# kubectl describe nodes k8s-node1
...
Taints:             <none>
...

推荐文章

Docker-打包镜像