1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-05 12:46:18 +01:00
Files
openshift-docs/modules/microshift-nw-create-http-based-route.adoc

74 lines
2.2 KiB
Plaintext

// Module included in the following assemblies:
//
// * microshift_networking/microshift-configuring-routes.adoc
:_mod-docs-content-type: PROCEDURE
[id="microshift-nw-creating-a-route_{context}"]
= Creating an HTTP-based route
[role="_abstract"]
To host your application at a public URL by using the basic HTTP routing protocol, create an HTTP-based route. This configuration exposes a service on an unsecured application port, allowing external access without TLS encryption.
A route can either be secure or unsecured, depending on the network security configuration of your application.
The following procedure describes how to create a simple HTTP-based route to a web application, using the `hello-microshift` application as an example.
.Prerequisites
* You installed the {oc-first}.
* You have access to your {microshift-short} node.
* You have a web application that exposes a port and a TCP endpoint listening for traffic on the port.
.Procedure
. Create a service called `hello-microshift` by running the following command:
+
[source,terminal]
----
$ oc expose pod hello-microshift -n $namespace
----
. Create an unsecured route to the `hello-microshift` application by running the following command:
+
[source,terminal]
----
$ oc expose svc/hello-microshift --hostname=microshift.com $namespace
----
.Verification
* Verify that the `route` resource was created by running the following command:
+
[source,terminal]
----
$ oc get routes -o yaml <name of resource> -n $namespace
----
* `namespace`: Specifies the route that is named `hello-microshift` and the namespace is named `hello-microshift`.
+
.Sample YAML definition for the created unsecured route
[source,yaml]
----
apiVersion: route.openshift.io/v1
kind: Route
metadata:
name: hello-microshift
namespace: hello-microshift
spec:
host: microshift.com
port:
targetPort: 8080
to:
kind: Service
name: hello-microshift
----
+
where:
+
`spec.host`:: Specifies the hostname.
`port.targetPort`:: Specifies the target port for the router to map the endpoint port in the service.
+
[NOTE]
====
{microshift-short} does not 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.
====