|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * networking/routes/route-configuration.adoc |
| 4 | + |
| 5 | +[id="nw-creating-a-route_{context}"] |
| 6 | += Creating an HTTP-based route |
| 7 | + |
| 8 | +A route allows you to host your application at a public URL. It can either be secure or unsecured, depending on the network security configuration of your application. An HTTP-based route is an unsecured route that uses the basic HTTP routing protocol and exposes a service on an unsecured application port. |
| 9 | + |
| 10 | +The following procedure describes how to create a simple HTTP-based route to a web application, using the `hello-openshift` application as an example. |
| 11 | +//link:https://github.com/openshift/origin/tree/master/examples/hello-openshift[hello-openshift] |
| 12 | + |
| 13 | +.Prerequisites |
| 14 | + |
| 15 | + |
| 16 | +* You installed the OpenShift CLI (`oc`). |
| 17 | +* You are logged in as an administrator. |
| 18 | +* You have a web application that exposes a port and a TCP endpoint listening for traffic on the port. |
| 19 | + |
| 20 | +.Procedure |
| 21 | + |
| 22 | +. Create a project called `hello-openshift` by running the following command: |
| 23 | ++ |
| 24 | +[source,terminal] |
| 25 | +---- |
| 26 | +$ oc new-project hello-openshift |
| 27 | +---- |
| 28 | + |
| 29 | +. Create a pod in the project by running the following command: |
| 30 | ++ |
| 31 | +[source,terminal] |
| 32 | +---- |
| 33 | +$ oc create -f https://raw.githubusercontent.com/openshift/origin/master/examples/hello-openshift/hello-pod.json |
| 34 | +---- |
| 35 | + |
| 36 | +. Create a service called `hello-openshift` by running the following command: |
| 37 | ++ |
| 38 | +[source,terminal] |
| 39 | +---- |
| 40 | +$ oc expose pod/hello-openshift |
| 41 | +---- |
| 42 | + |
| 43 | +. Create an unsecured route to the `hello-openshift` application by running the following command: |
| 44 | ++ |
| 45 | +[source,terminal] |
| 46 | +---- |
| 47 | +$ oc expose svc hello-openshift |
| 48 | +---- |
| 49 | ++ |
| 50 | +If you examine the resulting `Route` resource, it should look similar to the following: |
| 51 | ++ |
| 52 | +.YAML definition of the created unsecured route: |
| 53 | +[source,yaml] |
| 54 | +---- |
| 55 | +apiVersion: route.openshift.io/v1 |
| 56 | +kind: Route |
| 57 | +metadata: |
| 58 | + name: hello-openshift |
| 59 | +spec: |
| 60 | + host: hello-openshift-hello-openshift.<Ingress_Domain> <1> |
| 61 | + port: |
| 62 | + targetPort: 8080 |
| 63 | + to: |
| 64 | + kind: Service |
| 65 | + name: hello-openshift |
| 66 | +---- |
| 67 | +<1> `<Ingress_Domain>` is the default ingress domain name. |
| 68 | ++ |
| 69 | +[NOTE] |
| 70 | +==== |
| 71 | +To display your default ingress domain, run the following command: |
| 72 | +[source,terminal] |
| 73 | +---- |
| 74 | +$ oc get ingresses.config/cluster -o jsonpath={.spec.domain} |
| 75 | +---- |
| 76 | +==== |
0 commit comments