1、查看集群节点信息
[root@k8s-master1 ~]# kubectl get nodes
2、定义标签
# 定义k8s-node1标签为worker1,定义k8s-node2标签为worker2,定义k8s-node3标签为worker3
[root@k8s-master1 ~]# kubectl label node k8s-node1 kubernetes.io/role=worker1
node/k8s-node1 labeled
[root@k8s-master1 ~]# kubectl label node k8s-node2 kubernetes.io/role=worker2
node/k8s-node2 labeled
[root@k8s-master1 ~]# kubectl label node k8s-node3 kubernetes.io/role=worker3
node/k8s-node3 labeled
# 定义k8s-master1、k8s-master2、k8s-master3标签为master
[root@k8s-master1 ~]# kubectl label node k8s-master1 kubernetes.io/role=master
node/k8s-master1 labeled
[root@k8s-master1 ~]# kubectl label node k8s-master2 kubernetes.io/role=master
node/k8s-master2 labeled
[root@k8s-master1 ~]# kubectl label node k8s-master3 kubernetes.io/role=master
node/k8s-master3 labeled
[root@k8s-master1 ~]# kubectl get nodes
3、更换标签
[root@k8s-master1 ~]# kubectl label nodes k8s-node1 kubernetes.io/role=worker --overwrite
node/k8s-node1 labeled
[root@k8s-master1 ~]# kubectl label nodes k8s-node2 kubernetes.io/role=worker --overwrite
node/k8s-node2 labeled
[root@k8s-master1 ~]# kubectl label nodes k8s-node3 kubernetes.io/role=worker --overwrite
node/k8s-node3 labeled
[root@k8s-master1 ~]# kubectl get nodes
4、移除标签
[root@k8s-master1 ~]# kubectl label nodes k8s-node1 kubernetes.io/role-
node/k8s-node1 unlabeled
[root@k8s-master1 ~]# kubectl label nodes k8s-node2 kubernetes.io/role-
node/k8s-node2 unlabeled
[root@k8s-master1 ~]# kubectl label nodes k8s-node3 kubernetes.io/role-
node/k8s-node3 unlabeled
[root@k8s-master1 ~]# kubectl get nodes
若文章图片、下载链接等信息出错,请在评论区留言反馈,博主将第一时间更新!如本文“对您有用”,欢迎随意打赏,谢谢!
评论