Run one command in a container
POST/api/namespaces/:namespace/pods/:name/exec
Permission: pods:exec in the namespace of the path (permissions).
command is an argv array and is not run in a shell (for pipes, pass ["sh", "-c", "…"]).
No stdin. Output is kept up to 1 MiB per stream; the rest is dropped and truncated is true,
but the command runs to its end. timeoutSeconds 1–120 (default 30): past it the output so far
comes back with exitCode: -1 and truncated: true (Kubernetes does not stop the process; it
may run on in the container). A non-zero exit code is a normal answer (200).
Output is text: bytes that are not UTF-8 come back as U+FFFD, so pipe binary output through base64.
Recorded like a shell (Admin → Recordings, "command"); the audit log keeps the program name
(command[0]), never the whole command line.
Request
Responses
- 200
- 400
- 403
- 404
- 429
- 503
The command ran (whatever its exit code).
Bad body, container_not_found or not_ready (the container is not running).
forbidden, api_access_policy or feature_disabled.
pod_not_found
too_many_sessions: your shells and commands at once are over the limit.
recording_unavailable: a command run with an API key is always recorded, and recording failed.