That’s easy!
Add Label:
kubectl label node <node name> node-role.kubernetes.io/<role name>=<key — (any name)>
Remove label:
kubectl label node <node name> node-role.kubernetes.io/<role name>-
Let’s try:
$ kubectl get nodes
1 2 3 4 |
NAME STATUS ROLES AGE VERSION node-1.domain.loc Ready master 51d v1.17.0 node-2.domain.loc Ready <none> 51d v1.17.0 node-3.domain.loc Ready <none> 51d v1.17.0 |
$ kubectl label node node-2.domain.loc node-role.kubernetes.io/worker=
1 |
node/node-2.domain.loc labeled |
and check:
$ kubectl get nodes
1 2 3 4 |
NAME STATUS ROLES AGE VERSION node-1.domain.loc Ready master 51d v1.17.0 node-2.domain.loc Ready worker 51d v1.17.0 node-3.domain.loc Ready <none> 51d v1.17.0 |