We use the below command to display pods with a specific label:

We could also display the pods and their labels using the below command:

Modifying a pod's label on the fly:

Below is an example of Yaml file of a pod named - pod-label -:

We create the pod using the below command:

We check if our pod was created, using the below command - -l for label -:

Then, we use the below command to modify the "app=nginx" label to "app=nginx-1" for the - pod-label - pod, using the below command:

We could check whether the label has been modified, using the below command, and looking for the "Labels: app=nginx-1" line":

We could delete the label with the "app" key using the "kubectl label" command:

To add a new label to our "pod-label" pod, we use the below command:

Brando Sabatini and Ikbal C ©. Powered by Blogger.