设置k8s中节点node的ROLES值
1.查看集群
[root@k8s-master ~]# kubectl get nodes
NAME STATUS ROLES AGE VERSION
k8s-master Ready control-plane,master 54d v1.23.8
k8s-node1 Ready <none> 54d v1.23.8
k8s-node2 Ready <none> 54d v1.23.8
2. 给node节点修改roles
其实这个Roles就是一个标签,执行以下命令给node1 和 node2 打上worker标签
k8s-node1 打上标签为worker1
k8s-node2 打上标签为worker2文章来源地址https://www.toymoban.com/news/detail-784368.html
kubectl label node k8s-node1 kubernetes.io/role=worker1
kubectl label node k8s-node2 kubernetes.io/role=worker2
[root@k8s-master ~]# kubectl label node k8s-node2 kubernetes.io/role=worker2
node/k8s-node2 labeled
[root@k8s-master ~]# kubectl label node k8s-node1 kubernetes.io/role=worker1
node/k8s-node1 labeled
[root@k8s-master ~]# kubectl get nodes
NAME STATUS ROLES AGE VERSION
k8s-master Ready control-plane,master 54d v1.23.8
k8s-node1 Ready worker1 54d v1.23.8
k8s-node2 Ready worker2 54d v1.23.8
[root@k8s-master ~]#
3.更换为其他的标签
kubectl label nodes k8s-node1 kubernetes.io/role=worker --overwrite
kubectl label nodes k8s-node2 kubernetes.io/role=worker --overwrite
[root@k8s-master ~]# kubectl label nodes k8s-node1 kubernetes.io/role=worker --overwrite
node/k8s-node1 unlabeled
[root@k8s-master ~]# kubectl label nodes k8s-node2 kubernetes.io/role=worker --overwrite
node/k8s-node2 unlabeled
[root@k8s-master ~]# kubectl get nodes
NAME STATUS ROLES AGE VERSION
k8s-master Ready control-plane,master 54d v1.23.8
k8s-node1 Ready worker 54d v1.23.8
k8s-node2 Ready worker 54d v1.23.8
[root@k8s-master ~]#
4. 不想要标签想移除标签
kubectl label nodes k8s-node1 kubernetes.io/role-
kubectl label nodes k8s-node2 kubernetes.io/role-
[root@k8s-master ~]# kubectl get nodes
NAME STATUS ROLES AGE VERSION
k8s-master Ready control-plane,master 54d v1.23.8
k8s-node1 Ready <none> 54d v1.23.8
k8s-node2 Ready <none> 54d v1.23.8
[root@k8s-master ~]#
大家对K8S的使用有啥问题,欢迎留言我给大家解答。
文章来源:https://www.toymoban.com/news/detail-784368.html
到了这里,关于设置k8s中节点node的ROLES值,K8S集群怎么修改node1的集群ROLES的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!