Skip to content

Conversation

Flying-Tom
Copy link
Contributor

No description provided.

@kmesh-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign lizhencheng9527 for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @Flying-Tom, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request adds new documentation that serves as a practical guide for setting up and testing global rate limiting functionality in kmesh. The document details the deployment of necessary components, configuration of traffic rules using an external rate limiting service, and verification of rate limiting behavior across multiple proxy instances, providing a clear path for users to implement robust traffic management.

Highlights

  • New Documentation: Introduces a comprehensive guide for implementing and testing global rate limiting within the kmesh environment.
  • Step-by-Step Setup: Provides detailed instructions covering the deployment of Kmesh, Istiod, sample services (sleep, httpbin), Redis for state management, and an external Envoy rate limiting service.
  • EnvoyFilter Configuration: Demonstrates how to configure an EnvoyFilter to inject global rate limiting rules into a Waypoint proxy, including header-based rate limits for different quotas.
  • Testing and Verification: Includes practical test cases using curl to verify the rate limiting behavior for 'low', 'medium', and default quotas, along with steps to inspect Envoy configurations and rate limiting service logs.
  • Conceptual Differences: Outlines the key distinctions between global and local rate limiting, focusing on shared state, external service dependency, network impact, scalability, and configuration.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

netlify bot commented Sep 16, 2025

Deploy Preview for kmesh-net ready!

Name Link
🔨 Latest commit d58836a
🔍 Latest deploy log https://app.netlify.com/projects/kmesh-net/deploys/68c8f071aaae910008c087ac
😎 Deploy Preview https://deploy-preview-237--kmesh-net.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds comprehensive documentation for setting up and testing global rate limiting with kmesh. The guide is well-structured and covers all the necessary steps from deployment to verification. I've provided a few suggestions to improve clarity and ensure the reproducibility of the examples, such as using specific version tags for images instead of latest or master, rephrasing a heading for better readability, and refining the test commands to make the output easier to interpret.

spec:
containers:
- name: ratelimit
image: envoyproxy/ratelimit:master

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using the master tag for the envoyproxy/ratelimit image is not ideal for documentation as it points to a potentially unstable version. To ensure users can reliably follow these steps, it's better to use a specific, stable version tag.

Suggested change
image: envoyproxy/ratelimit:master
image: envoyproxy/ratelimit:<SPECIFIC_STABLE_VERSION>

Next, create a dedicated Waypoint proxy for the `httpbin` service and label the service to direct its traffic through this Waypoint.

```sh
kmeshctl waypoint apply -n default --name httpbin-waypoint --image ghcr.io/kmesh-net/waypoint:latest

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using the :latest tag for the waypoint image can lead to inconsistencies for users following this guide over time. Pinning to a specific version tag ensures that the documentation remains accurate and reproducible.

Suggested change
kmeshctl waypoint apply -n default --name httpbin-waypoint --image ghcr.io/kmesh-net/waypoint:latest
kmeshctl waypoint apply -n default --name httpbin-waypoint --image ghcr.io/kmesh-net/waypoint:<SPECIFIC_VERSION>

istioctl proxy-config all $WAYPOINT_POD -ojson | grep ratelimit -A 20
```

## Step 8. Find the following results, which means the configuration has been sent to waypoint

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This heading is a bit long and awkward. A more concise title would improve readability.

Suggested change
## Step 8. Find the following results, which means the configuration has been sent to waypoint
## Step 8. Verify the Configuration

Comment on lines +319 to +322
kubectl exec -it $SLEEP_POD -- curl -H 'quota:medium' http://httpbin:8000/headers
kubectl exec -it $SLEEP_POD -- curl -H 'quota:medium' http://httpbin:8000/headers
kubectl exec -it $SLEEP_POD -- curl -H 'quota:medium' http://httpbin:8000/headers
kubectl exec -it $SLEEP_POD -- curl -H 'quota:medium' http://httpbin:8000/headers

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The test commands output full response headers, which makes it harder to quickly verify if rate limiting is working. Modifying the curl command to show only the HTTP status code would make the result much clearer for the user.

Suggested change
kubectl exec -it $SLEEP_POD -- curl -H 'quota:medium' http://httpbin:8000/headers
kubectl exec -it $SLEEP_POD -- curl -H 'quota:medium' http://httpbin:8000/headers
kubectl exec -it $SLEEP_POD -- curl -H 'quota:medium' http://httpbin:8000/headers
kubectl exec -it $SLEEP_POD -- curl -H 'quota:medium' http://httpbin:8000/headers
kubectl exec -it $SLEEP_POD -- curl -s -o /dev/null -w '%{http_code}\n' -H 'quota:medium' http://httpbin:8000/headers
kubectl exec -it $SLEEP_POD -- curl -s -o /dev/null -w '%{http_code}\n' -H 'quota:medium' http://httpbin:8000/headers
kubectl exec -it $SLEEP_POD -- curl -s -o /dev/null -w '%{http_code}\n' -H 'quota:medium' http://httpbin:8000/headers
kubectl exec -it $SLEEP_POD -- curl -s -o /dev/null -w '%{http_code}\n' -H 'quota:medium' http://httpbin:8000/headers

Comment on lines +332 to +333
kubectl exec -it $SLEEP_POD -- curl -H 'quota:low' http://httpbin:8000/headers
kubectl exec -it $SLEEP_POD -- curl -H 'quota:low' http://httpbin:8000/headers

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency and clarity, this test case would also benefit from showing only the HTTP status code. This makes it immediately obvious when the rate limit is triggered.

Suggested change
kubectl exec -it $SLEEP_POD -- curl -H 'quota:low' http://httpbin:8000/headers
kubectl exec -it $SLEEP_POD -- curl -H 'quota:low' http://httpbin:8000/headers
kubectl exec -it $SLEEP_POD -- curl -s -o /dev/null -w '%{http_code}\n' -H 'quota:low' http://httpbin:8000/headers
kubectl exec -it $SLEEP_POD -- curl -s -o /dev/null -w '%{http_code}\n' -H 'quota:low' http://httpbin:8000/headers

Without any quota header, requests are subject to the default limit of 10 requests per second globally.

```sh
for i in {1..12}; do kubectl exec -it $SLEEP_POD -- curl http://httpbin:8000/headers; done

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The output of this loop can be hard to parse. By changing the curl command to only output the HTTP status code, you can make it much easier for the user to see exactly when the rate limit is enforced.

Suggested change
for i in {1..12}; do kubectl exec -it $SLEEP_POD -- curl http://httpbin:8000/headers; done
for i in {1..12}; do kubectl exec -it $SLEEP_POD -- curl -s -o /dev/null -w '%{http_code}\n' http://httpbin:8000/headers; done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants