Main Menu

Search

KUBERNETES: Steps To Set Label For Kubernetes Nodes (DevOps)


1. List Kubernetest nodes and list the current labels using below command.

kubectl get node --show-labels

Below is sample output. As we can see there is no label set for worker1 node. In this example we will set label to worker1 node.
 
NAME STATUS ROLES AGE VERSION LABELS
primary.example.com Ready master 37m v1.18.10 beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/arch=amd64,kubernetes.io/hostname=primary.example.com,kubernetes.io/os=linux,node-role.kubernetes.io/master=
worker1.example.com Ready <none> 7m41s v1.18.10 beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/arch=amd64,kubernetes.io/hostname=worker1.example.com,kubernetes.io/os=linux

2. Set the label for the Kubernetes node using below command.
 
# kubectl label node <node name> node-role.kubernetes.io/<label>=
 
 
For e.g in this case set the label for the Kubernetes worker1 node using below command.

# kubectl label node worker1.example.com node-role.kubernetes.io/worker1=
 
Below is sample output.

node/worker1.example.com labeled

3. List Kubernetes nodes using below command and check if the label is set.

# kubectl get nodes

NAME STATUS ROLES AGE VERSION
primary.example.com Ready master 40m v1.18.10
worker1.example.com Ready worker1 10m v1.18.10


Products to which Article Applies

Kubernetes 

Search Keywords: Kubernetes Kube kubectl command commands k8s how to label name naming change changing custom node nodes container containers step detailed set setting default

Article Author: Tarun Boyella

 

No comments:

Post a Comment