设置k8s中节点node的ROLES值,K8S集群怎么修改node1的集群ROLES
设置k8s中节点node的ROLES值,K8S集群怎么修改node1的集群ROLES
·
设置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
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的使用有啥问题,欢迎留言我给大家解答。
更多推荐
已为社区贡献47条内容
所有评论(0)