标签前:
general@master-node:~$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
master-node Ready master 23m v1.18.2
slave-node Ready <none> 19m v1.18.2
kubectl label nodes <your_node> kubernetes.io/role=<your_label>
在我的情况下,从节点例如
kubectl label nodes slave-node kubernetes.io/role=worker
标签后:
general@master-node:~$ kubectl label nodes slave-node kubernetes.io/role=worker
node/slave-node labeled
general@master-node:~$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
master-node Ready master 24m v1.18.2
slave-node Ready worker 21m v1.18.2
您也可以更改标签。 就放--overwrite
kubectl label --overwrite nodes <your_node> kubernetes.io/role=<your_new_label>
例如
kubectl label --overwrite nodes slave-node kubernetes.io/role=worker1
覆盖标签后:
general@master-node:~$ kubectl label --overwrite nodes slave-node kubernetes.io/role=worker1
node/slave-node labeled
general@master-node:~$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
master-node Ready master 36m v1.18.2
slave-node Ready worker1 32m v1.18.2