You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/content/guides/advanced-routing.md
+17-33Lines changed: 17 additions & 33 deletions
Original file line number
Diff line number
Diff line change
@@ -6,19 +6,13 @@ toc: true
6
6
docs: "DOCS-000"
7
7
---
8
8
9
-
In this guide we will configure advanced routing rules for multiple applications. These rules will showcase request
10
-
matching by path, headers, query parameters, and method. For an introduction to exposing your application, it is
11
-
recommended to go through the [basic guide]({{< relref "/guides/routing-traffic-to-your-app.md" >}}) first.
9
+
In this guide we will configure advanced routing rules for multiple applications. These rules will showcase request matching by path, headers, query parameters, and method. For an introduction to exposing your application, we recommend that you go through the [basic guide]({{< relref "/guides/routing-traffic-to-your-app.md" >}}) first.
12
10
13
11
The following image shows the traffic flow that we will be creating with these rules.
The goal is to create a set of rules that will result in client requests being sent to specific backends based on
18
-
the request attributes. In this diagram, we have two versions of the `coffee` service. Traffic for v1 needs to be
19
-
directed to the old application, while traffic for v2 needs to be directed towards the new application. We also
20
-
have two `tea` services, one that handles GET operations and one that handles POST operations. Both the `tea`
21
-
and `coffee` applications share the same Gateway.
15
+
The goal is to create a set of rules that will result in client requests being sent to specific backends based on the request attributes. In this diagram, we have two versions of the `coffee` service. Traffic for v1 needs to be directed to the old application, while traffic for v2 needs to be directed towards the new application. We also have two `tea` services, one that handles GET operations and one that handles POST operations. Both the `tea` and `coffee` applications share the same Gateway.
### Deploy the Gateway API Resources for the Coffee Applications
47
41
48
-
The [Gateway](https://gateway-api.sigs.k8s.io/api-types/gateway/) resource is typically deployed by the
49
-
[cluster operator](https://gateway-api.sigs.k8s.io/concepts/roles-and-personas/#roles-and-personas_1). To deploy the Gateway:
42
+
The [Gateway](https://gateway-api.sigs.k8s.io/api-types/gateway/) resource is typically deployed by the [cluster operator](https://gateway-api.sigs.k8s.io/concepts/roles-and-personas/#roles-and-personas_1). To deploy the Gateway:
50
43
51
44
```yaml
52
45
kubectl apply -f - <<EOF
@@ -65,8 +58,7 @@ EOF
65
58
66
59
This Gateway defines a single listener on port 80. Since no hostname is specified, this listener matches on all hostnames.
67
60
68
-
The [HTTPRoute](https://gateway-api.sigs.k8s.io/api-types/httproute/) is typically deployed by the
69
-
[application developer](https://gateway-api.sigs.k8s.io/concepts/roles-and-personas/#roles-and-personas_1). To deploy the `coffee` HTTPRoute:
61
+
The [HTTPRoute](https://gateway-api.sigs.k8s.io/api-types/httproute/) is typically deployed by the [application developer](https://gateway-api.sigs.k8s.io/concepts/roles-and-personas/#roles-and-personas_1). To deploy the `coffee` HTTPRoute:
70
62
71
63
```yaml
72
64
kubectl apply -f - <<EOF
@@ -109,21 +101,19 @@ EOF
109
101
110
102
This HTTPRoute has a few important properties:
111
103
112
-
- The `parentRefs` references the Gateway resource that we created, and specifically defines the `http` listener
113
-
to attach to, via the `sectionName` field.
104
+
- The `parentRefs` references the Gateway resource that we created, and specifically defines the `http` listener to attach to, via the `sectionName` field.
114
105
-`cafe.example.com` is the hostname that is matched for all requests to the backends defined in this HTTPRoute.
115
-
- The first rule defines that all requests with the path prefix `/coffee` and no other matching conditions are sent
116
-
to the `coffee-v1` Service.
117
-
- The second rule defines two matching conditions. If *either* of these conditions match, requests are forwarded to
118
-
the `coffee-v2` Service:
106
+
- The first rule defines that all requests with the path prefix `/coffee` and no other matching conditions are sent to the `coffee-v1` Service.
107
+
- The second rule defines two matching conditions. If *either* of these conditions match, requests are forwarded to the `coffee-v2` Service:
108
+
119
109
- Request with the path prefix `/coffee` and header `version=v2`
120
110
- Request with the path prefix `/coffee` and the query parameter `TEST=v2`
121
-
If you want both conditions to be required, you can define headers and queryParams in the same match object.
111
+
112
+
If you want both conditions to be required, you can define headers and queryParams in the same match object.
122
113
123
114
### Send Traffic to Coffee
124
115
125
-
Using the external IP address and port for NGINX Gateway Fabric, we can send traffic to our coffee
126
-
applications.
116
+
Using the external IP address and port for NGINX Gateway Fabric, we can send traffic to our coffee applications.
127
117
128
118
{{< note >}}If you have a DNS record allocated for `cafe.example.com`, you can send the request directly to that hostname, without needing to resolve.{{< /note >}}
129
119
@@ -138,8 +128,7 @@ Server address: 10.244.0.9:8080
138
128
Server name: coffee-v2-68bd55f798-s9z5q
139
129
```
140
130
141
-
If we want our request to be routed to `coffee-v2`, then we need to meet the defined conditions. We can include
142
-
a header:
131
+
If we want our request to be routed to `coffee-v2`, then we need to meet the defined conditions. We can include a header:
@@ -160,8 +149,7 @@ Server name: coffee-v2-68bd55f798-s9z5q
160
149
161
150
## Tea Applications
162
151
163
-
Let's deploy a different set of applications now called `tea` and `tea-post`. These applications will
164
-
have their own set of rules, but will still attach to the same Gateway listener as the `coffee` apps.
152
+
Let's deploy a different set of applications now called `tea` and `tea-post`. These applications will have their own set of rules, but will still attach to the same Gateway listener as the `coffee` apps.
165
153
166
154
### Deploy the Tea Applications
167
155
@@ -213,8 +201,7 @@ The properties of this HTTPRoute include:
213
201
214
202
### Send Traffic to Tea
215
203
216
-
Using the external IP address and port for NGINX Gateway Fabric, we can send traffic to our tea
217
-
applications.
204
+
Using the external IP address and port for NGINX Gateway Fabric, we can send traffic to our tea applications.
218
205
219
206
{{< note >}}If you have a DNS record allocated for `cafe.example.com`, you can send the request directly to that hostname, without needing to resolve.{{< /note >}}
220
207
@@ -240,16 +227,14 @@ Server address: 10.244.0.7:8080
240
227
Server name: tea-post-b59b8596b-g586r
241
228
```
242
229
243
-
This request should receive a response from the `tea-post` Pod. Any other type of method, such as PATCH, will
244
-
result in a `404 Not Found` response.
230
+
This request should receive a response from the `tea-post` Pod. Any other type of method, such as PATCH, will result in a `404 Not Found` response.
245
231
246
232
247
233
## Troubleshooting
248
234
249
235
If you have any issues while sending traffic, try the following to debug your configuration and setup:
250
236
251
-
- Make sure you set the shell variables $GW_IP and $GW_PORT to the public IP and port of the NGINX Gateway Fabric
252
-
Service. Instructions for finding those values are [here](/docs/installation.md#expose-nginx-gateway-fabric).
237
+
- Make sure you set the shell variables $GW_IP and $GW_PORT to the public IP and port of the NGINX Gateway Fabric Service. Instructions for finding those values are [here](/docs/installation.md#expose-nginx-gateway-fabric).
253
238
254
239
- Check the status of the Gateway:
255
240
@@ -307,8 +292,7 @@ If you have any issues while sending traffic, try the following to debug your co
307
292
Name: http
308
293
```
309
294
310
-
Check that the conditions match and that the attached routes for the `http` listener equals 2. If it is less than
311
-
2, there may be an issue with the routes.
295
+
Check that the conditions match and that the attached routes for the `http` listener equals 2. If it is less than 2, there may be an issue with the routes.
0 commit comments