技术流ken

运维拯救世界

k8s设置集群角色

查看所有的node节点

[root@k8s-master1 ~]# kubectl get no
NAME          STATUS                     ROLES    AGE   VERSION
k8s-master1   Ready,SchedulingDisabled   <none>   29d   v1.20.14
k8s-master2   Ready,SchedulingDisabled   <none>   29d   v1.20.14
k8s-master3   Ready,SchedulingDisabled   <none>   29d   v1.20.14
k8s-node1     Ready                      <none>   29d   v1.20.14
k8s-node2     Ready                      <none>   29d   v1.20.14
k8s-node3     Ready                      <none>   29d   v1.20.14
k8s-node4     Ready                      <none>   29d   v1.20.14
k8s-node5     Ready                      <none>   29d   v1.20.14
k8s-node6     Ready                      <none>   29d   v1.20.14
k8s-node7     Ready                      <none>   29d   v1.20.14
k8s-node8     Ready                      <none>   29d   v1.20.14
k8s-node9     Ready                      <none>   29d   v1.20.14


设置集群角色

# 设置k8s-master 为 master 角色
[root@k8s-master1 ~]# kubectl label nodes k8s-master1 node-role.kubernetes.io/master=
[root@k8s-master1 ~]# kubectl label nodes k8s-master2 node-role.kubernetes.io/master=
[root@k8s-master1 ~]# kubectl label nodes k8s-master3 node-role.kubernetes.io/master=



# 设置 node 为 node 角色
[root@k8s-master1 ~]# kubectl label nodes k8s-node2 node-role.kubernetes.io/node=
node/k8s-node2 labeled
[root@k8s-master1 ~]# kubectl label nodes k8s-node3 node-role.kubernetes.io/node=
node/k8s-node3 labeled
[root@k8s-master1 ~]# kubectl label nodes k8s-node4 node-role.kubernetes.io/node=
node/k8s-node4 labeled
[root@k8s-master1 ~]# kubectl label nodes k8s-node5 node-role.kubernetes.io/node=
node/k8s-node5 labeled
[root@k8s-master1 ~]# kubectl label nodes k8s-node6 node-role.kubernetes.io/node=
node/k8s-node6 labeled
[root@k8s-master1 ~]# kubectl label nodes k8s-node7 node-role.kubernetes.io/node=
node/k8s-node7 labeled
[root@k8s-master1 ~]# kubectl label nodes k8s-node8 node-role.kubernetes.io/node=
node/k8s-node8 labeled
[root@k8s-master1 ~]# kubectl label nodes k8s-node9 node-role.kubernetes.io/node=
node/k8s-node9 labeled


# 设置 master 一般情况下不接受负载
kubectl taint nodes test1 node-role.kubernetes.io/master=true:NoSchedule

master运行pod

kubectl taint nodes test1 node-role.kubernetes.io/master-

master不运行pod

kubectl taint nodes test1 node-role.kubernetes.io/master=:NoSchedule

 

发表评论

邮箱地址不会被公开。