设置master调度_去除master污点
转载自:https://www.modb.pro/db/424007
===============
使用kubeadm初始化的集群,默认情况下,出于安全考虑Pod不会被调度到Master Node上,不参与工作负载。在某些资源有限的情况下,需要允许master节点部署pod,可以设置去除Master节点污点,使Master节点可以承担工作负载。
1. 查看所有节点taint状态
当前共2个节点,一个master,一个node
[root@rh-node01 ~]# kubectl describe nodes | grep -E '(Roles|Taints)'
Roles: control-plane
Taints: node-role.kubernetes.io/control-plane:NoSchedule
Roles: <none>
Taints: <none>
2. 去除所有节点的master Taint状态
使所有master01均可被调度
[root@node01 ~]# kubectl taint nodes --all node-role.kubernetes.io/master-
taint "node-role.kubernetes.io/master" not found
taint "node-role.kubernetes.io/master" not found
当前提示,表示master已无Traint设置。
3. 查看master01的Traint状态
none表示当前已无Traint设置
[root@node01 ~]# kubectl describe nodes master01 |grep Taint
Taints: <none>
4. 验证
创建pod验证,应当前只有两个节点,故生成2副本的http pod
[root@node01 ~]# kubectl create deployment --image=nginx --replicas=2 http
deployment.apps/http created
如果节点数量较多,可提高replicas数量,不低于节点数量,如20节点的集群,--replicas=20,这样明显看到pod分布。
注:如果想只起两个副本且必须分配到两个机器上 请参考nodeSelector以及亲和性和反亲和性的的用法。
[root@node01 ~]# kubectl get pods -o wide #会发现此时master节点上已经分配了一个Pod
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
http-7d57549bfd-hwkdh 1/1 Running 0 66s 10.244.1.2 node01.cbg.cn <none> <none>
http-7d57549bfd-v9bj7 1/1 Running 0 66s 10.244.0.4 master01.cbg.cn <none> <none>
5. 参考
http://t.zoukankan.com/xlovepython-p-14468772.html
https://blog.csdn.net/weixin_41303815/article/details/109202136
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 记一次.NET内存居高不下排查解决与启示