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
* Adds new boolean field "any" to internal httpMatch object. An httpMatch with any=true represents a path-only match.
Any request sent to the path will satisfy this match.
* Changes algorithm for sorting routes to match the rules defined by the spec.
* Adds local development instructions for njs module as well as test coverage output.
* Updates advanced-routing example to demonstrate new capabilities.
Copy file name to clipboardExpand all lines: examples/advanced-routing/README.md
+40-32Lines changed: 40 additions & 32 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,10 @@
3
3
In this example we will deploy NGINX Kubernetes Gateway and configure advanced routing rules for a simple cafe application.
4
4
We will use `HTTPRoute` resources to route traffic to the cafe application based on a combination of the request method, headers, and query parameters.
5
5
6
+
The cafe application consists of four services: `coffee-v1-svc`, `coffee-v2-svc`, `tea-svc`, and `tea-post-svc`. In the next section we will create the following routing rules for the cafe application:
7
+
- For the path `/coffee` route requests with the header `version` set to `v2` or with the query param `TEST` set to `v2` to `coffee-v2-svc`, and all other requests to `coffee-v1-svc`.
8
+
- For the path `/tea` route POST requests to `tea-post-svc`, and all other requests, such as `GET` requests, to `tea-svc`.
9
+
6
10
## Running the Example
7
11
8
12
## 1. Deploy NGINX Kubernetes Gateway
@@ -33,9 +37,11 @@ We will use `HTTPRoute` resources to route traffic to the cafe application based
33
37
34
38
```
35
39
kubectl -n default get pods
36
-
NAME READY STATUS RESTARTS AGE
37
-
coffee-6f4b79b975-2sb28 1/1 Running 0 12s
38
-
tea-6fb46d899f-fm7zr 1/1 Running 0 12s
40
+
NAME READY STATUS RESTARTS AGE
41
+
coffee-v1-75869cf7ff-vlfpq 1/1 Running 0 17m
42
+
coffee-v2-67499ff985-2k6cc 1/1 Running 0 17m
43
+
tea-6fb46d899f-hjzwr 1/1 Running 0 17m
44
+
tea-post-648dfcdd6c-2rlqb 1/1 Running 0 17m
39
45
```
40
46
41
47
## 3. Configure Routing
@@ -48,51 +54,53 @@ We will use `HTTPRoute` resources to route traffic to the cafe application based
48
54
49
55
## 4. Test the Application
50
56
51
-
We will use `curl` to send requests to the `coffee` and `tea`services.
57
+
We will use `curl` to send requests to the `/coffee` and `/tea`endpoints of the cafe application.
52
58
53
59
### 4.1 Access coffee
54
60
55
-
Send a `POST`request to the path `/coffee` with the headers `X-Demo-Header:Demo-X1` and `version:v1`:
61
+
Send a request with the header `version:v2` and confirm that the response comes from `coffee-v2-svc`:
56
62
57
-
```
58
-
curl --resolve cafe.example.com:$GW_PORT:$GW_IP http://cafe.example.com:$GW_PORT/coffee -X POST -H "X-Demo-Header:Demo-X1" -H "version:v1"
0 commit comments