|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * configuring_ingress_cluster_traffic/configuring-ingress-cluster-traffic-ingress-controller.adoc |
| 4 | +// * networking/routes/route-configuration.adoc |
| 5 | + |
| 6 | +:_content-type: PROCEDURE |
| 7 | +[id="nw-ingress-sharding-route-configuration_{context}"] |
| 8 | += Creating a route for Ingress Controller sharding |
| 9 | + |
| 10 | +A route allows you to host your application at a URL. In this case, the hostname is not set and the route uses a subdomain instead. When you specify a subdomain, you automatically use the domain of the Ingress Controller that exposes the route. For situations where a route is exposed by multiple Ingress Controllers, the route is hosted at multiple URLs. |
| 11 | + |
| 12 | +The following procedure describes how to create a route for Ingress Controller sharding, using the `hello-openshift` application as an example. |
| 13 | + |
| 14 | +Ingress Controller sharding is useful when balancing incoming traffic load among a set of Ingress Controllers and when isolating traffic to a specific Ingress Controller. For example, company A goes to one Ingress Controller and company B to another. |
| 15 | + |
| 16 | +.Prerequisites |
| 17 | + |
| 18 | +* You installed the OpenShift CLI (`oc`). |
| 19 | +* You are logged in as a project administrator. |
| 20 | +* You have a web application that exposes a port and an HTTP or TLS endpoint listening for traffic on the port. |
| 21 | +* You have configured the Ingress Controller for sharding. |
| 22 | +
|
| 23 | +.Procedure |
| 24 | + |
| 25 | +. Create a project called `hello-openshift` by running the following command: |
| 26 | ++ |
| 27 | +[source,terminal] |
| 28 | +---- |
| 29 | +$ oc new-project hello-openshift |
| 30 | +---- |
| 31 | + |
| 32 | +. Create a pod in the project by running the following command: |
| 33 | ++ |
| 34 | +[source,terminal] |
| 35 | +---- |
| 36 | +$ oc create -f https://raw.githubusercontent.com/openshift/origin/master/examples/hello-openshift/hello-pod.json |
| 37 | +---- |
| 38 | + |
| 39 | +. Create a service called `hello-openshift` by running the following command: |
| 40 | ++ |
| 41 | +[source,terminal] |
| 42 | +---- |
| 43 | +$ oc expose pod/hello-openshift |
| 44 | +---- |
| 45 | + |
| 46 | +. Create a route definition called `hello-openshift-route.yaml`: |
| 47 | ++ |
| 48 | +.YAML definition of the created route for sharding: |
| 49 | +[source,yaml] |
| 50 | +---- |
| 51 | +apiVersion: route.openshift.io/v1 |
| 52 | +kind: Route |
| 53 | +metadata: |
| 54 | + labels: |
| 55 | + type: sharded <1> |
| 56 | + name: hello-openshift-edge |
| 57 | + namespace: hello-openshift |
| 58 | +spec: |
| 59 | + subdomain: hello-openshift <2> |
| 60 | + tls: |
| 61 | + termination: edge |
| 62 | + to: |
| 63 | + kind: Service |
| 64 | + name: hello-openshift |
| 65 | +---- |
| 66 | +<1> Both the label key and its corresponding label value must match the ones specified in the Ingress Controller. In this example, the Ingress Controller has the label key and value `type: sharded`. |
| 67 | +<2> The route will be exposed using the value of the `subdomain` field. When you specify the `subdomain` field, you must leave the hostname unset. If you specify both the `host` and `subdomain` fields, then the route will use the value of the `host` field, and ignore the `subdomain` field. |
| 68 | + |
| 69 | +. Use `hello-openshift-route.yaml` to create a route to the `hello-openshift` application by running the following command: |
| 70 | ++ |
| 71 | +[source,terminal] |
| 72 | +---- |
| 73 | +$ oc -n hello-openshift create -f hello-openshift-route.yaml |
| 74 | +---- |
| 75 | + |
| 76 | +.Verification |
| 77 | +* Get the status of the route with the following command: |
| 78 | ++ |
| 79 | +[source,terminal] |
| 80 | +---- |
| 81 | +$ oc -n hello-openshift get routes/hello-openshift-edge -o yaml |
| 82 | +---- |
| 83 | ++ |
| 84 | +The resulting `Route` resource should look similar to the following: |
| 85 | ++ |
| 86 | +.Example output |
| 87 | +[source,yaml] |
| 88 | +---- |
| 89 | +apiVersion: route.openshift.io/v1 |
| 90 | +kind: Route |
| 91 | +metadata: |
| 92 | + labels: |
| 93 | + type: sharded |
| 94 | + name: hello-openshift-edge |
| 95 | + namespace: hello-openshift |
| 96 | +spec: |
| 97 | + subdomain: hello-openshift |
| 98 | + tls: |
| 99 | + termination: edge |
| 100 | + to: |
| 101 | + kind: Service |
| 102 | + name: hello-openshift |
| 103 | +status: |
| 104 | + ingress: |
| 105 | + - host: hello-openshift.<apps-sharded.basedomain.example.net> <1> |
| 106 | + routerCanonicalHostname: router-sharded.<apps-sharded.basedomain.example.net> <2> |
| 107 | + routerName: sharded <3> |
| 108 | +---- |
| 109 | +<1> The hostname the Ingress Controller, or router, uses to expose the route. The value of the `host` field is automatically determined by the Ingress Controller, and uses its domain. In this example, the domain of the Ingress Controller is `<apps-sharded.basedomain.example.net>`. |
| 110 | +<2> The hostname of the Ingress Controller. |
| 111 | +<3> The name of the Ingress Controller. In this example, the Ingress Controller has the name `sharded`. |
0 commit comments