Bootstrap FreeKB - OpenShift - Create insecured Route using the oc expose command
OpenShift - Create insecured Route using the oc expose command

Updated:   |  OpenShift articles

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

There are a few different ways to route external requests to a pod / service.

An OpenShift route or an Ingress route will provide a URL such as which is used to route a request onto a service, which is then routed onto a pod, and then to the container in the pod, and finally to the application running in the container.


Like this.


The oc expose service command can be used to create an insecured route, whereas the oc create route command is used to create a secured route.

The oc get services command can be used to list the services that have been created in the currently selected. Let's say you want to create an OpenShift route that will be used to route requests to my-service.

~]# oc get services
NAME             TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE
my-service       ClusterIP   <none>        8080/TCP       114d


The oc expose service command can be used to create a route that will be used to route requests onto a service. Often, the following options are used.

  • --name - to give your route a certain name
  • --port - The port that the service is listening on
  • --label - I'm not sure why, but I have to use this to get the route exposed on the default router
  • --hostname - By default, hostname will be <route name>-<project/namespace>-<ingress domain name>:<port><optional endpoint> (e.g. The --hostname option can be used to specify the hostname.
~]$ oc expose service my-service --name my-route --port 8080 --labels route-type=default exposed


The oc get routes command can then be used the list the routes. In this example, the route URL is The syntax of the URL is <route name>-<project/namespace>-<ingress domain name>:<port><optional endpoint>.

~]# oc get routes
NAME          HOST/PORT                                       PATH   SERVICES    PORT     TERMINATION WILDCARD
my-route         my-service  8080-tcp             None


The oc describe route command can be used to display more details about the route. Notice that the route has been exposed on router default.

~]$ oc describe route my-route
Name:                   my-route
Namespace:              my-project
Created:                17 minutes ago
Labels:                 name=my-route
Requested Host:
                           exposed on router default (host 17 minutes ago
Path:                   /example
TLS Termination:        <none>
Insecure Policy:        <none>
Endpoint Port:          8080

Service:        my-service
Weight:         100 (100%)


The default router pod should be in the openshift-ingress project/namespace.

~]$ oc get pod --namespace openshift-ingress
NAME                             READY   STATUS    RESTARTS      AGE
router-default-f6d44996c-sljgl   1/1     Running   2 (58m ago)   56d


The router pods run an haproxy (high availability proxy) load balancer, which can be seen with the oc exec command.

~]$ oc exec pod/router-default-76c5c89559-dclkw --namespace openshift-ingress -- cat /var/lib/haproxy/conf/haproxy.config | grep my-route
  server pod:my-pod:my-service:8080-tcp: cookie 15b9071e86b87a2b4b6f976291de96cf weight 256 check inter 5000ms


If the application in the pod is a web based application, you should now be able to interact with the application using the route URL.


Or using curl.

~]# curl
Hello OpenShift!


Did you find this article helpful?

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


Add a Comment

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