This is a pretty simple lab, we are going to explore labels. You can use labels to organize, group, or select API objects.
For example, pods are "tagged" with labels, and then services use label selectors to identify the pods they proxy to. This makes it possible for services to reference groups of pods, even treating pods with potentially different docker containers as related entities.
In a previous lab we added our web app using a S2I template. When we did that, OpenShift labeled our objects for us. Let's look at the labels on our running pod.
$ oc get pods
$ oc describe pod/dc-metro-map-4-v427r | grep Labels: --context=4
Namespace: demo-0
Priority: 0
Node: ip-10-0-186-15.us-east-2.compute.internal/10.0.186.15
Start Time: Thu, 29 Jul 2021 19:33:13 +0000
Labels: app=dc-metro-map
deployment=dc-metro-map-4
deploymentconfig=dc-metro-map
Annotations: k8s.v1.cni.cncf.io/network-status:
[{
You can see the Labels automatically added contain the app, deployment, and deploymentconfig. Let's add a new label to this pod.
$ oc label pod/<POD NAME> testyear=2021 testedby=me
$ oc describe pod/<POD NAME> | grep Labels: --context=4
Namespace: demo-0
Priority: 0
Node: ip-10-0-186-15.us-east-2.compute.internal/10.0.186.15
Start Time: Thu, 29 Jul 2021 19:33:13 +0000
Labels: app=dc-metro-map
deployment=dc-metro-map-4
deploymentconfig=dc-metro-map
testedby=me
testyear=2021
In a previous lab we added our web app using a S2I template. When we did that, OpenShift labeled our objects for us. Let's look at the labels on our running pod.
That's it for this lab. Now you know that all the objects in OpenShift can be labeled. This is important because those labels can be used as part of your CI/CD process. An upcoming lab will cover using labels for Blue/Green deployments. Labels can also be used for running your apps on specific nodes (e.g. just on SSD nodes or just on east coast nodes).