How to add roles to nodes in Kubernetes?

This worked for me:

kubectl label node cb2.4xyz.couchbase.com node-role.kubernetes.io/worker=worker

NAME                                          STATUS    ROLES           AGE       VERSION
cb2.4xyz.couchbase.com                          Ready     custom,worker   35m       v1.11.1
cb3.5xyz.couchbase.com                          Ready     worker          29m       v1.11.1

I could not delete/update the old label, but I can live with it.


A node role is just a label with the format node-role.kubernetes.io/<role>

You can add this yourself with kubectl label


Default
enter image description here

Add Role

kubectl label node <node name> node-role.kubernetes.io/<role name>=<key - (any name)>

enter image description here

Remove Role

kubectl label node <node name> node-role.kubernetes.io/<role name>-

enter image description here