OpenShift - Label a pod using the oc label command

If you are not familiar with the oc command, refer to OpenShift - Getting Started with the oc command.

A node contains one or more pods, and each pod contains one or more containers.


The oc label pod command can be used to apply one or more labels to a pod. In this example, label region=east is applied to the pod named my-app-c4v5h.

~]$ oc label pod my-app-c4v5h region=east
pod/my-app-c4v5h labeled


And the oc describe pod command can be used to see the labels that have been applied to the pod.

~]$ oc describe pod my-app-c4v5h
Name:         my-app-c4v5h
Namespace:    foo
Priority:     0
Node:         worker-hsjrp/
Start Time:   Tue, 26 Jul 2022 07:22:41 -0500
Labels:       region=east


And here is how you can remove a label. In this example, the region label will be removed.

~]$ oc label pod my-app-c4v5h region-
pod/my-app-c4v5h labeled


Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee

Add a Comment

We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.

Please enter f8245 in the box below so that we can be sure you are a human.


Web design by yours truely - me, myself, and I   |   |