From ba38a72cfcd691f80c3119bb3f332673a5266e1d Mon Sep 17 00:00:00 2001 From: aicee Date: Tue, 9 Sep 2025 10:39:29 +0800 Subject: [PATCH] add circuit breaker and local rate limit doc Signed-off-by: aicee --- docs/application-layer/circuit-breaker.md | 152 ++++++++++++ docs/application-layer/local-rate-limiting.md | 225 ++++++++++++++++++ 2 files changed, 377 insertions(+) create mode 100644 docs/application-layer/circuit-breaker.md create mode 100644 docs/application-layer/local-rate-limiting.md diff --git a/docs/application-layer/circuit-breaker.md b/docs/application-layer/circuit-breaker.md new file mode 100644 index 00000000..28a03401 --- /dev/null +++ b/docs/application-layer/circuit-breaker.md @@ -0,0 +1,152 @@ +--- +title: Circuit Breaker +sidebar_position: 10 +--- + +This document provides a step-by-step guide on how to test the circuit breaking functionality of kmesh. It covers deploying the necessary components, configuring traffic rules, and observing the circuit breaking behavior. + +## Step 1. Deploy kmesh + +Please read [Quick Start](https://kmesh.net/docs/setup/quick-start) to complete the deployment of kmesh. + +## Step 2. Deploy fortio and httpbin + +``` sh +kubectl apply -f -< /dev/null || \ + { kubectl kustomize "github.com/kubernetes-sigs/gateway-api/config/crd/experimental?ref=444631bfe06f3bcca5d0eadf1857eac1d369421d" | kubectl apply -f -; } +``` + +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 +kubectl label service httpbin istio.io/use-waypoint=httpbin-waypoint +``` + +## Step 4. Configure DestinationRule + +```sh +kubectl apply -f - <=1.24) + +Please read [Quick Start](https://kmesh.net/docs/setup/quick-start) to complete the deployment of kmesh. + +## Step 2. Deploy sleep and httpbin + +We will deploy `httpbin` as the backend service for receiving requests and `sleep` as the client for sending requests. + +``` sh +kubectl apply -f samples/sleep/sleep.yaml +kubectl apply -f samples/httpbin/httpbin.yaml +``` + +## Step 3. Deploy waypoint for httpbin + +First, if you haven't installed the Kubernetes Gateway API CRDs, run the following command to install. + +``` sh +kubectl get crd gateways.gateway.networking.k8s.io &> /dev/null || \ + { kubectl kustomize "github.com/kubernetes-sigs/gateway-api/config/crd/experimental?ref=444631bfe06f3bcca5d0eadf1857eac1d369421d" | kubectl apply -f -; } +``` + +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 + +kubectl label service httpbin istio.io/use-waypoint=httpbin-waypoint +``` + +## Step 4. Deploy envoyFilter + +This `EnvoyFilter` resource injects a local rate-limiting filter into the `httpbin` service's Waypoint proxy. The filter is configured with the following rules: + +- A request with the header `quota: low` will be limited to **1 request per 300 seconds**. +- A request with the header `quota: medium` will be limited to **3 requests per 300 seconds**. +- Other requests will be subject to a default limit of **10 requests per 300 seconds**. + +The `workloadSelector` ensures that this filter is applied only to the `httpbin-waypoint` proxy. + +```sh +kubectl apply -f -<