Skip to content

Latest commit

 

History

History
70 lines (50 loc) · 2.34 KB

routes.adoc

File metadata and controls

70 lines (50 loc) · 2.34 KB

Lab: Creating Routes by Exposing Services

Application description

In this lab, we’re going to make our application visible to the end users, so they can access it.

Application architecture

Background: Routes

While Services provide internal abstraction and load balancing within an OpenShift environment, sometimes clients (users, systems, devices, etc.) outside of OpenShift need to access an application. The way that external clients are able to access applications running in OpenShift is through the OpenShift routing layer. And the data object behind that is a Route.

The default OpenShift router (HAProxy) uses the HTTP header of the incoming request to determine where to proxy the connection. You can optionally define security, such as TLS, for the Route. If you want your Services, and, by extension, your Pods, to be accessible to the outside world, you need to create a Route.

Exercise: Creating a Route

Fortunately, creating a Route is a pretty straight-forward process. You simply expose the Service via the command line. Or, via the web console, just click the "Create Route" button associated with the service.

First we want to verify that we don’t already have any existing routes:

$ oc get routes
No resources found.

Now we need to get the Service name to expose:

$ oc get services

NAME       CLUSTER-IP       EXTERNAL-IP   PORT(S)    AGE
parksmap   172.30.169.213   <none>        8080/TCP   5h

Once we know the Service name, creating a Route is a simple one-command task:

$ oc expose service parksmap
route "parksmap" exposed

Verify the Route was created with the following command:

$ oc get route
NAME       HOST/PORT                                              PATH      SERVICES   PORT       TERMINATION
parksmap   parksmap-{{EXPLORE_PROJECT_NAME}}{{USER_SUFFIX}}.{{ROUTER_ADDRESS}}             parksmap   8080-tcp

You can also verify the Route by looking at the project in the OpenShift web console:

Route

Pretty nifty, huh? This application is now available at the URL shown in the web console. Click the link and you will see:

Route