Skip to content

Commit 8d2ffb4

Browse files
[codex] docs: explain k8s proxy benefits (#847)
* docs: explain k8s proxy benefits Signed-off-by: Asish Kumar <officialasishkumar@gmail.com> * docs: add Kubernetes architecture image Signed-off-by: Asish Kumar <officialasishkumar@gmail.com> * docs(k8s-proxy): update REST API section for in-cluster automation Refine the documentation for the Kubernetes Proxy REST API, emphasizing that all console actions are accessible via REST calls. Removed details about the MCP server and its tools, focusing instead on the available endpoints for recording, testing, and status monitoring. Signed-off-by: Asish Kumar <officialasishkumar@gmail.com> * chore: update Kubernetes architecture image Replaced the existing k8s-arch.png with a new version to enhance visual representation of the architecture. Signed-off-by: Asish Kumar <officialasishkumar@gmail.com> * docs(k8s-proxy): correct capitalization in documentation Updated the capitalization of "Keploy Enterprise" in the Kubernetes Proxy API documentation for consistency and clarity. Signed-off-by: Asish Kumar <officialasishkumar@gmail.com> * docs(k8s-proxy): remove local CI replay section Drop the Local CI replay point from the v4.0.0 k8s proxy API docs to keep the page aligned with the requested scope. Made-with: Cursor Signed-off-by: Asish Kumar <officialasishkumar@gmail.com> --------- Signed-off-by: Asish Kumar <officialasishkumar@gmail.com>
1 parent 294eed9 commit 8d2ffb4

3 files changed

Lines changed: 48 additions & 10 deletions

File tree

static/img/k8s-arch.png

1.46 MB
Loading

versioned_docs/version-4.0.0/keploy-cloud/kubernetes.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ This guide walks you through creating a local **Kind** Kubernetes cluster and co
3737
> [!NOTE]
3838
> This documentation covers **local Kind cluster** setup. Documentation for **hosted cluster** setup is coming soon.
3939
40+
## How Keploy works on Kubernetes
41+
42+
![How Keploy works on Kubernetes architecture overview](/img/k8s-arch.png)
43+
4044
---
4145

4246
## Prerequisites

versioned_docs/version-4.0.0/running-keploy/k8s-proxy-api.md

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,53 @@ The same `/record/start`, `/record/stop`, `/test/start`, `/deployments`, and rep
4848

4949
---
5050

51-
## Why the Kubernetes Proxy instead of `keploy enterprise` directly?
51+
## Why the Kubernetes Proxy instead of Keploy Enterprise directly?
5252

53-
Running the Keploy enterprise CLI inside a Pod works, but it is a per-app, per-node model: each Deployment you want to record needs its own sidecar plumbing, image rebuild, or pod restart. The Kubernetes Proxy removes that friction:
53+
Running the Keploy enterprise CLI inside a Pod works, but it is a per-app, per-node model: each Deployment you want to record needs its own sidecar plumbing, image rebuild, or pod restart. The Kubernetes Proxy is a single in-cluster control plane that turns _record-and-replay_ into a few API calls, and layers on top of that a set of capabilities you do not get when you run the agent on its own. The benefits below are the reason teams pick the proxy over wiring the CLI in by hand.
5454

55-
- **Zero-touch agent setup.** The proxy registers a `MutatingAdmissionWebhook` (`/mutate`) so the Keploy recording agent is injected into target Pods on the next rollout. No image rebuild, sidecar template change, or per-app config knob is required.
56-
- **One API for every Deployment.** A single shared-token-authenticated endpoint starts or stops recording for any Deployment in the watched scope. `podsCount` controls how many pods are recorded and is capped by the Deployment replicas or HPA max replicas.
57-
- **Cluster-wide or namespace-scoped.** Install once per cluster, or set `watchNamespace` to pin the proxy to a single team's namespace. Cross-namespace calls are rejected with `403`.
58-
- **Stored session outputs.** Recording, replay, and schema-coverage outputs are persisted through the configured platform storage. Per-session and proxy logs are available through the log endpoints when log retention/support-bundle storage is enabled.
59-
- **Auto-replay loop.** A recording session can kick off an auto-replay on a cadence (`autoReplayInterval`) against freshly recorded test sets, giving you self-validating live traffic without a separate pipeline.
60-
- **Self-updating.** The proxy can roll itself (and the injected agent) forward via `POST /proxy/update`, so upgrades do not require kubectl or a GitOps round-trip—unless you _want_ GitOps to stay authoritative (the proxy detects and reports reverts).
61-
- **Static deduplication at the edge.** Enable `static_dedup` in the recording config to drop schema-identical traffic _before_ it is ever written as a test case. See [Static Deduplication](/docs/keploy-cloud/static-deduplication/).
55+
### 1. Auto-replay
6256

63-
---
57+
The proxy auto-replays captured traffic against a fresh Pod and reports back which captures behave as deterministic tests. This happens continuously while you record (every `autoReplayInterval` minutes, default 5) and once more, against any trailing captures, the moment you call `POST /record/stop`. The whole loop collapses the "record now, find out tomorrow which tests are flaky" wait into the recording session itself.
58+
59+
This is also why replay belongs in the Kubernetes Proxy instead of a one-off CLI run: the proxy has the cluster, Deployment, release, and recording-session context needed to make replay release-aware. For a new-release flow, the proxy layer is designed to coordinate replaying the traffic captured for the new release together with the historical traffic the service has recorded before, so a release is checked against both the latest behavior and the behavior users already depended on. When the smart test set gets shipped, that historical input becomes the curated smart set: newly recorded traffic plus the latest duplicate-free version of the service's long-lived test coverage.
60+
61+
Each test case is exercised once against a freshly rolled Pod and classified into one of three buckets:
62+
63+
- **Pass:** kept as a real, stable test case.
64+
- **High-risk failure:** marked as failed (a real regression to investigate).
65+
- **Low-risk failure with extractable noise:** marked as noisy and kept in the test set but excluded from failure counts. These are typically captures whose only diff is a timestamp, request-ID, or generated UUID. If the proxy cannot extract the noisy fields, the capture is kept as a failed test case so it can be investigated.
66+
67+
While the proxy is at it, mocks the test case did not actually need are pruned. So even if the original Pod made 200 dependency calls per request, the final test case only carries the mocks it depended on, and your test sets stay tiny.
68+
69+
The cadence is configured via `autoReplayInterval` (see [Auto-replay configuration](#auto-replay-configuration) below). When auto-replay runs as part of a re-record job, the proxy first asks the API server which suites passed last time. Replay still runs against the recorded test sets, but suite linking is gated so only suites that passed upstream and pass the fresh replay are linked forward.
70+
71+
### 2. Deduplication
72+
73+
A naive recorder turns a load test of `GET /users/42` into 50,000 identical test cases. Keploy's deduplication keeps the canonical capture, counts the rest, and drops them, so a real test set comes out of even a noisy production traffic sample.
74+
75+
Enable per-recording with `record_config.static_dedup`, and optionally narrow the dedup key per endpoint with `record_config.custom_dedup_fields`, which declares which JSON paths in the request body, plus method/path/status, define "the same test." The agent enforces this _at capture time_ before anything is written to storage, and per-pod dedup stats stream back into the recording status endpoint so you can watch duplicates being dropped live. See [Static Deduplication](/docs/keploy-cloud/static-deduplication/) for the full configuration reference.
76+
77+
### 3. REST API for in-cluster automation
78+
79+
Every action you perform from the Console or `kubectl-keploy` is also available as a REST call. The [endpoint reference](#endpoint-reference) covers the full surface—`/record/start`, `/record/stop`, `/test/start`, `/deployments`, `/proxy/update`, the streaming status endpoints, the log and report endpoints, and the `/k8s-proxy/*` data routes the Console uses for stored test cases, mocks, schema, and reports.
80+
81+
### 4. Schema Generation and Management
82+
83+
**Schema generation and per-release storage.** Recording produces a free OpenAPI 3.0.3 schema as a side effect. The proxy infers it from the captured traffic, so the spec reflects the requests and responses Keploy actually observed during that recording. Schema records store namespace, deployment, app name, app release, cluster name, and tenant metadata; release-specific versions are selected by `appRelease`, which is typically your image tag or git SHA. That lets `orders-api@v1.4.2` and `orders-api@v1.4.3` be stored as separate release snapshots instead of overwriting each other. Coverage reporting layered on top tells you which endpoints have been exercised, and how deeply. Endpoints are documented under [Reports and schema coverage](#reports-and-schema-coverage).
84+
85+
**Schema-conflict detection during auto-replay.** During auto-replay, the proxy fetches the latest stored schema, generates a schema from the recorded test cases, and merges the two. If replay produces failed test-case details, the report records a schema conflict and stores the new schema accordingly. Compatible same-release additions update the existing schema; new releases or replay-detected conflicts insert a new schema document.
86+
87+
### 5. Smart test set (Upcoming)
88+
89+
The direct user benefit is simple: this layer is meant to maintain a smart, replay-ready test set for the service instead of leaving you to manage scattered recording sessions by hand. The goal is to keep the latest useful, duplicate-free version of the behavior your service has recorded over time. When you add an API endpoint, the new behavior can be folded in; when you delete an endpoint, stale coverage can be removed; when you change a request or response shape, the latest captured version can replace the old one. Future release replays can then run the newly recorded traffic plus this smart test set instead of every duplicate capture ever seen, which keeps replay fast, efficient, and easier to trust as a CI gate.
90+
91+
Current auto-replay already performs the in-session curation work:
92+
93+
- **Cross-pod uniqueness within a session.** When a Deployment with `replicas=5` records into the same session, each pod's local `test-N` counter does not collide with any other pod's. The proxy keeps them distinct so you don't end up with five different captures all named `test-1`.
94+
- **Noise vs. failure separation.** During auto-replay, captures with extractable timestamp/UUID-style diffs are tagged as noisy and kept in the test set (excluded from failure counts), while real regressions and low-risk captures without extractable noise are tagged as failures. The noise tag itself is useful information because it tells later replays which fields to ignore for that endpoint.
95+
- **Fresh-capture curation.** Current auto-replay curates the test sets produced by the active recording session. Historical test set consolidation support exists in the codebase, but it is not active in the current record/start path.
96+
97+
Combined with capture-time static deduplication (benefit 2), this keeps the current replay set small, stable, and CI-gateable even when the underlying traffic is noisy.
6498

6599
## Authentication
66100

0 commit comments

Comments
 (0)