-
Notifications
You must be signed in to change notification settings - Fork 132
Add documentation for Request Routing in Kmesh (L7 capability) #1469
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,93 @@ | ||||||||||||||
|
|
||||||||||||||
| # Request Routing in Kmesh | ||||||||||||||
|
|
||||||||||||||
| This document explains how to configure HTTP request routing at Layer 7 using Kmesh. Request routing allows you to control how traffic is directed to different backend services based on URL paths. | ||||||||||||||
|
|
||||||||||||||
| ## Prerequisites | ||||||||||||||
|
|
||||||||||||||
| Before starting, you should have: | ||||||||||||||
|
|
||||||||||||||
| - A Kubernetes cluster with Istio and Kmesh installed | ||||||||||||||
| - Gateway API CRDs applied | ||||||||||||||
| - Deployed services, such as httpbin and sleep | ||||||||||||||
| - The appropriate label set on your namespace to enable Kmesh | ||||||||||||||
|
|
||||||||||||||
| ## Use Case: Path-Based Routing | ||||||||||||||
|
|
||||||||||||||
| This example routes traffic to two different versions of the httpbin service, depending on the requested URL path. | ||||||||||||||
|
|
||||||||||||||
| - Requests to paths beginning with /v1 are sent to httpbin-v1 | ||||||||||||||
| - Requests to paths beginning with /v2 are sent to httpbin-v2 | ||||||||||||||
|
|
||||||||||||||
| ## Step 1: Deploy Sample Workloads | ||||||||||||||
|
|
||||||||||||||
| ```bash | ||||||||||||||
| kubectl create namespace example | ||||||||||||||
| kubectl label namespace example istio.io/dataplane-mode=Kmesh | ||||||||||||||
| kubectl apply -n example -f samples/httpbin/httpbin-v1.yaml | ||||||||||||||
| kubectl apply -n example -f samples/httpbin/httpbin-v2.yaml | ||||||||||||||
| kubectl apply -n example -f samples/sleep/sleep.yaml | ||||||||||||||
| ``` | ||||||||||||||
|
|
||||||||||||||
| ## Step 2: Define Gateway and Route | ||||||||||||||
|
|
||||||||||||||
| Save this configuration as http-route.yaml | ||||||||||||||
|
|
||||||||||||||
| ```yaml | ||||||||||||||
| apiVersion: gateway.networking.k8s.io/v1beta1 | ||||||||||||||
| kind: HTTPRoute | ||||||||||||||
| meta | ||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||
| name: http-route | ||||||||||||||
| namespace: example | ||||||||||||||
| spec: | ||||||||||||||
| parentRefs: | ||||||||||||||
| - name: example-gateway | ||||||||||||||
|
Comment on lines
+43
to
+44
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The example relies on an I suggest the following changes to make the example self-contained:
Suggested change
|
||||||||||||||
| rules: | ||||||||||||||
| - matches: | ||||||||||||||
| - path: | ||||||||||||||
| type: PathPrefix | ||||||||||||||
| value: /v1 | ||||||||||||||
| backendRefs: | ||||||||||||||
| - name: httpbin-v1 | ||||||||||||||
| port: 8000 | ||||||||||||||
| - matches: | ||||||||||||||
| - path: | ||||||||||||||
| type: PathPrefix | ||||||||||||||
| value: /v2 | ||||||||||||||
| backendRefs: | ||||||||||||||
| - name: httpbin-v2 | ||||||||||||||
| port: 8000 | ||||||||||||||
| ``` | ||||||||||||||
|
|
||||||||||||||
| Apply the configuration: | ||||||||||||||
|
|
||||||||||||||
| ```bash | ||||||||||||||
| kubectl apply -f http-route.yaml | ||||||||||||||
| ``` | ||||||||||||||
|
|
||||||||||||||
| ## Step 3: Verify Routing | ||||||||||||||
|
|
||||||||||||||
| Open a shell in the sleep pod | ||||||||||||||
|
|
||||||||||||||
| ```bash | ||||||||||||||
| kubectl -n example exec deploy/sleep -- bash | ||||||||||||||
| ``` | ||||||||||||||
|
|
||||||||||||||
| From within the pod, run | ||||||||||||||
|
|
||||||||||||||
| ```bash | ||||||||||||||
| curl http://httpbin.example.svc.cluster.local:8000/v1/status/200 | ||||||||||||||
| curl http://httpbin.example.svc.cluster.local:8000/v2/status/200 | ||||||||||||||
| ``` | ||||||||||||||
|
|
||||||||||||||
| You should see that the path for /v1 gets a response from httpbin-v1 and /v2 gets a response from httpbin-v2. | ||||||||||||||
|
|
||||||||||||||
| ## Notes and Limitations | ||||||||||||||
|
|
||||||||||||||
| Header-based and regex path matching may require further validation. These instructions assume the example-gateway resource is present and working as expected. | ||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||
|
|
||||||||||||||
| ## Related References | ||||||||||||||
|
|
||||||||||||||
| Kmesh issue <https://github.com/kmesh-net/kmesh/issues/600> | ||||||||||||||
|
|
||||||||||||||
| Istio Request Routing: <https://istio.io/latest/docs/tasks/traffic-management/request-routing> | ||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we already have this doc, ref: https://kmesh.net/docs/application-layer/try-request-routing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for pointing that out! Yes, I noticed the existing documentation and my PR focuses on testing or demonstrating the process specifically on the macOS platform. I wanted to share my experience to help macOS users better follow the steps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AkarshSahlot If this is for macos, i am not sure kmesh works. If it can work on mac os. Can you please update the install guide rather than for each task