Skip to content

Commit 2cbecc3

Browse files
committed
OSDOCS-3621: add spec.subdomain enhancement
1 parent d07d362 commit 2cbecc3

File tree

3 files changed

+118
-1
lines changed

3 files changed

+118
-1
lines changed
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
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`.

networking/configuring_ingress_cluster_traffic/configuring-ingress-cluster-traffic-ingress-controller.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,14 @@ include::modules/nw-creating-project-and-service.adoc[leveloffset=+1]
4444

4545
include::modules/nw-exposing-service.adoc[leveloffset=+1]
4646

47+
// Router sharding
4748
ifdef::openshift-enterprise,openshift-webscale,openshift-origin[]
4849
include::modules/nw-ingress-sharding-route-labels.adoc[leveloffset=+1]
4950

5051
include::modules/nw-ingress-sharding-namespace-labels.adoc[leveloffset=+1]
5152

53+
include::modules/nw-ingress-sharding-route-configuration.adoc[leveloffset=+1]
54+
5255
[role="_additional-resources"]
5356
== Additional resources
5457

networking/routes/route-configuration.adoc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ toc::[]
1111

1212
//Creating an insecure route
1313
include::modules/nw-creating-a-route.adoc[leveloffset=+1]
14-
//
14+
15+
// Creating a route for router sharding
16+
include::modules/nw-ingress-sharding-route-configuration.adoc[leveloffset=+1]
17+
1518
//Creating route timeouts
1619
include::modules/nw-configuring-route-timeouts.adoc[leveloffset=+1]
1720

0 commit comments

Comments
 (0)