|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * microshift_networking/microshift-configuring-routes.adoc |
| 4 | + |
| 5 | +:_mod-docs-content-type: PROCEDURE |
| 6 | +[id="microshift-nw-creating-a-route_{context}"] |
| 7 | += Creating an HTTP-based route |
| 8 | + |
| 9 | +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. |
| 10 | + |
| 11 | +The following procedure describes how to create a simple HTTP-based route to a web application, using the `hello-microshift` application as an example. |
| 12 | + |
| 13 | +.Prerequisites |
| 14 | +* You installed the OpenShift CLI (`oc`). |
| 15 | +* You have access to your {microshift-short} cluster. |
| 16 | +* You have a web application that exposes a port and a TCP endpoint listening for traffic on the port. |
| 17 | +
|
| 18 | +.Procedure |
| 19 | + |
| 20 | +. Create a service called `hello-microshift` by running the following command: |
| 21 | ++ |
| 22 | +[source,terminal] |
| 23 | +---- |
| 24 | +$ oc expose pod hello-microshift -n $namespace |
| 25 | +---- |
| 26 | + |
| 27 | +. Create an unsecured route to the `hello-microshift` application by running the following command: |
| 28 | ++ |
| 29 | +[source,terminal] |
| 30 | +---- |
| 31 | +$ oc expose svc/hello-microshift --hostname=microshift.com $namespace |
| 32 | +---- |
| 33 | + |
| 34 | +.Verification |
| 35 | + |
| 36 | +* Verify that the `route` resource was created by running the following command: |
| 37 | ++ |
| 38 | +[source,terminal] |
| 39 | +---- |
| 40 | +$ oc get routes -o yaml <name of resource> -n $namespace <1> |
| 41 | +---- |
| 42 | +<1> In this example, the route is named `hello-microshift` and the namespace is named `hello-microshift`. |
| 43 | +
|
| 44 | +.Sample YAML definition of the created unsecured route: |
| 45 | +[source,yaml] |
| 46 | +---- |
| 47 | +apiVersion: route.openshift.io/v1 |
| 48 | +kind: Route |
| 49 | +metadata: |
| 50 | + name: hello-microshift |
| 51 | + namespace: hello-microshift |
| 52 | +spec: |
| 53 | + host: microshift.com <1> |
| 54 | + port: |
| 55 | + targetPort: 8080 <2> |
| 56 | + to: |
| 57 | + kind: Service |
| 58 | + name: hello-microshift |
| 59 | +---- |
| 60 | +<1> Example hostname. |
| 61 | +<2> `targetPort` is required for the router to map the endpoint port in the service. |
| 62 | ++ |
| 63 | +[NOTE] |
| 64 | +==== |
| 65 | +{microshift-short} does not a use an API that creates a default ingress domain, but instead provides a wildcard for automatically generated domains. Each route can also define a separate hostname. |
| 66 | +==== |
0 commit comments