Bootstrap FreeKB - OpenShift - Label a route using the oc label command
OpenShift - Label a route using the oc label command

Updated:   |  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 the 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. Often this is used to label the route with a particular route type.

~]$ oc label route route001 route-type=default
route.route.openshift.io/route001 labeled

 

The oc get pods command can be used to list the pods in the openshift-ingress project / namespace. Notice there are default, internal and external routers. In this example, you could apply route-type=default or route-type=internal or route-type=external to the route. 

~]$ oc get pods --namespace openshift-ingress
NAME                                      READY   STATUS    RESTARTS   AGE
router-default-6f84fdff65-4zdmp           1/1     Running   0          57d
router-default-6f84fdff65-t7h22           1/1     Running   0          57d
router-default-6f84fdff65-z579b           1/1     Running   0          57d
router-external-router-7c7cf7cccd-2cgj5   1/1     Running   0          57d
router-external-router-7c7cf7cccd-8nj9d   1/1     Running   0          57d
router-internal-router-7c74f95ffd-dspfs   1/1     Running   0          57d
router-internal-router-7c74f95ffd-pfmsv   1/1     Running   0          57d

 

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 Buy Me A Coffee



Comments


Add a Comment


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