kubernetes集群角色管理
查看集群各节点角色:
[root@k8s-master-2 ~]# kubectl get nodes NAME STATUS ROLES AGE VERSION k8s-master-1 Ready master 45d v1.23.2 k8s-master-2 Ready control-plane,master 57d v1.23.2 k8s-master-3 Ready master 45d v1.23.2 k8s-node-1 Ready node 57d v1.23.2 k8s-node-2 Ready node 45d v1.23.2 k8s-node-3 Ready node 45d v1.23.2
设置角色:
# 将k8s-master-1设置为master角色
[root@k8s-master-2 ~]# kubectl label nodes k8s-master-1 node-role.kubernetes.io/master= node/k8s-master-1 labeled
# 将k8s-node-1设置为node角色 [root@k8s-master-2 ~]# kubectl label nodes k8s-node-1 node-role.kubernetes.io/node= node/k8s-node-1 labeled # 将k8s-master-1设置master角色,一般不接受负载
[root@k8s-msater-2 ~] kubectl taint nodes k8s-master-1 node-role.kubernetes.io/master=true:NoSchedule
# 将k8s-mster-1设置master运行pod
[root@k8s-master-2 ~] kubectl taint nodes k8s-master-1 node-role.kubernetes.io/master-
# 将k8s-master-1设置master不运行pod
[root@k8s-master-2 ~] kubectl taint nodes k8s-master-1 node-role.kubernetes.io/master=:NoSchedule
结束!