Skip to content

docs: authenticate to the Kubernetes Proxy with a service-account key or a PAT - #940

Draft
slayerjain wants to merge 7 commits into
mainfrom
docs/k8s-proxy-auth-service-accounts
Draft

slayerjain wants to merge 7 commits into
mainfrom
docs/k8s-proxy-auth-service-accounts

Conversation

@slayerjain

@slayerjain slayerjain commented Oct 24, 2026 •

Copy link
Copy Markdown
Member

What

The Kubernetes Proxy REST API page told every caller, CI pipelines included, to exchange a personal access token for the cluster's shared token (POST /get-shared-token, or the Console's Get Agent Token button) and to send that token on every call.

That token is the credential the proxy's own in-cluster components (the node agents and the replay runner) authenticate with. It names no user, so a copy held by a CI system carries cluster-wide authority with no owner and no per-consumer revocation. keploy/k8s-proxy#1126 makes the proxy accept the shared token only on the routes those components call, in every RBAC mode, and answer 403 everywhere else. That is a hard cut: there is no grace period and no release that only logs, so a script still sending the shared token gets the 403 from the upgrade on.

This PR moves the docs to what replaces it, which the proxy already accepts today.

  • Authentication sends a key straight in Authorization: Bearer <key>: a service-account key for CI and automation, or a PAT for a person. The section covers:
    • what a key can call (per-route permissions; enforce against the default audit mode);
    • setting up a service account for CI: a key bound to ITG_RUNNER for keploy cloud replay, or ATG_RUNNER for keploy test-suite --cloud, with key expiry and rotation;
    • the failure modes, and how long the proxy caches a validation.
  • Neither CI command starts or stops a recording or a replay through the proxy. Starting or stopping a recording or an in-cluster replay over the API (/record/start, /record/stop, /test/start, /test/stop) is a person's action, done with their own PAT. Under enforce that person needs the record or replay permissions on the cluster.
  • The PAT-to-shared-token exchange is documented as deprecated. The page shows the 403 the shared token now gets, with its MACHINE_CREDENTIAL_REFUSED code and its message, and explains how to migrate a script: send the key itself, and drop the exchange and any tokenId caching.
  • The quick start, the endpoint reference and the static-deduplication example use the key directly.
  • The endpoint reference says what POST /agent/execute-request reaches. It needs testgen:run and refuses the shared token. It sends a request only to an app Service the proxy manages, by its full in-cluster name, on one of the Service's ports, with TLS verified and redirects not followed. Any other target is a 403 that says why.
  • The failure table adds the multi-replica 503: a replica that cannot verify which replica owns a recording or replay forwards nothing. It answers OWNER_REPLICA_UNVERIFIED with a Retry-After header, and the fix is to let the proxy's service account get and list pods.
  • The Console menu paths are current: keys under Account › API Keys (the Generate new token button), service accounts under Account › Service Accounts, and the Get Agent Token button by its label. This covers the REST API page, smart-set-agent.md, k8s-proxy-llm-workflow.md and cloud-replay.md.

Ordering

Sending a PAT or a service-account key directly already works on current proxy releases, so the new instructions are safe to publish before the proxy change. The statements that the shared token gets 403 become true with the k8s-proxy release that carries keploy/k8s-proxy#1126. This PR should merge with that change or before it.

… or a PAT

The Kubernetes Proxy REST API page told callers, CI included, to trade a
personal access token for the cluster shared token and send that token on
every call. The shared token is the credential the proxy's own in-cluster
components use, and the proxy now accepts it only on the routes those
components call.

- Authentication now sends a service-account key (CI and automation) or a
  PAT (a person) straight in the Bearer header. It explains what a key can
  call (per-route permissions, enforce vs. the default audit mode), how to
  set up a service account for CI (ITG_RUNNER / ATG_RUNNER, key expiry and
  rotation), the failure modes, and how long the proxy caches a validation.
- The PAT -> shared-token exchange and the Console's Get Shared Token
  button are documented as deprecated, with the 403 the shared token now
  gets and how to migrate a script.
- The quick start, the endpoint reference and the static-deduplication
  example use the key directly.

Signed-off-by: slayerjain <shubhamkjain@outlook.com>
…on for keys

Signed-off-by: slayerjain <shubhamkjain@outlook.com>
… the shared-token cut is hard

The Kubernetes Proxy page told a CI job that starts and stops recordings
to borrow a cluster admin's key under enforce. CI does not start or stop
recordings: `keploy cloud replay` runs on a service-account key bound to
ITG_RUNNER and `keploy test-suite --cloud` on one bound to ATG_RUNNER,
and neither calls /record/start, /record/stop, /test/start or /test/stop.
Starting or stopping a recording or an in-cluster replay through the
proxy API is a person's action, done with their own PAT, which needs the
record or replay permissions on the cluster under enforce.

The deprecated shared-token section now says plainly that the
restriction is a hard cut: no grace period and no log-only release, so a
script still sending the shared token gets 403 on those routes from the
upgrade on, in every RBAC mode. Scripts can switch first, since the
proxy already accepts keys and PATs on every route.

Signed-off-by: slayerjain <shubhamkjain@outlook.com>
smart-set-agent.md, k8s-proxy-llm-workflow.md and cloud-replay.md still sent
readers to Settings → API Keys. The Console lists API Keys under its Account
menu, with a Generate new token button; say so, in the words k8s-proxy-api.md
already uses.

Signed-off-by: slayerjain <shubhamkjain@outlook.com>
…Token

The deprecated-exchange note named a "Get Shared Token" button. The Console
labels that button "Get Agent Token", so a reader looking for it found nothing.

Signed-off-by: slayerjain <shubhamkjain@outlook.com>
… code

The proxy's refusal of the cluster shared token now carries
"code": "MACHINE_CREDENTIAL_REFUSED" and a message that names the route
class. Quote that body, say a script can branch on the code instead of the
message, and say that /kms/decrypt is the one key-material route the token
may still call, and only over the proxy's own loopback listener.

Signed-off-by: slayerjain <shubhamkjain@outlook.com>
… OWNER_REPLICA_UNVERIFIED

The endpoint reference now says that POST /agent/execute-request needs
testgen:run, refuses the shared token, and sends a request only to an app
Service the proxy manages, by its full in-cluster name, with TLS verified
and redirects not followed; any other target is a 403 that says why.

The failure table adds the multi-replica 503: a replica that cannot verify
the replica owning a recording or replay does not forward the request, and
answers OWNER_REPLICA_UNVERIFIED with a Retry-After header.

Signed-off-by: slayerjain <shubhamkjain@outlook.com>
@slayerjain
slayerjain force-pushed the docs/k8s-proxy-auth-service-accounts branch from 442b5fa to 0b92b92 Compare October 25, 2026 05:34

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant