OpenShift - Label a route using the oc label command

by
Jeremy Canfield |
Updated: October 20 2022
| OpenShift articles
Let's say you use the oc expose service command to create a route named route001.
oc expose service service001 --name route001
The oc describe route command can be used to list labels the route has.
~]$ oc describe route route001
Name: route001
Namespace: foo
Created: About a minute ago
Labels: app=webserver54-openjdk8-tomcat9-openshift-rhel8
app.kubernetes.io/component=webserver54-openjdk8-tomcat9-openshift-rhel8
app.kubernetes.io/instance=webserver54-openjdk8-tomcat9-openshift-rhel8
The oc label route command can be used to apply additional labels to the route.
~]$ oc label route route001 route-type=default
route.route.openshift.io/route001 labeled
And the oc describe route command can be used again to see the additional labels that have been applied to the route.
~]$ oc describe route route001
Name: route001
Namespace: foo
Created: About a minute ago
Labels: app=webserver54-openjdk8-tomcat9-openshift-rhel8
app.kubernetes.io/component=webserver54-openjdk8-tomcat9-openshift-rhel8
app.kubernetes.io/instance=webserver54-openjdk8-tomcat9-openshift-rhel8
route-type=default
And here is how you can remove a label. In this example, the route-type label will be removed.
~]$ oc label route route001 route-type-
route.route.openshift.io/route001 labeled
Did you find this article helpful?
If so, consider buying me a coffee over at