Skip to main content
The Kubernetes Agent Sandbox runtime API as axed serves it: the REST endpoints and the process.v1 and watcher.v1 gRPC services. It is wire-compatible with sandboxd. sandboxd compatibility lists every intentional difference. The API is on by default. Turn it off with --agent-sandbox=false, which closes the REST port and removes the two gRPC services. The protos are copied unchanged from upstream: proto/process/v1/process.proto and proto/watcher/v1/watcher.proto.

Authentication

With --auth-token-file or --auth-token-sha256 set, every request needs the token except GET /v1/health and GET /readyz. Send either header (as gRPC metadata on gRPC calls):
A REST request without a valid token gets:
A gRPC call gets UNAUTHENTICATED.

REST conventions

  • Errors are JSON with Content-Type: application/json: {"code": "...", "message": "..."}, followed by a newline. Errors lists every code and status.
  • Success without a body is 204 No Content. This covers every PUT, DELETE and POST.
  • Unknown paths return 404 with an empty body.
  • Unsupported methods return 405 with an Allow header and the plain-text body method not allowed.
  • Booleans in the query accept 1, t, T, TRUE, true, True and 0, f, F, FALSE, false, False. An empty value or an absent parameter is false. Anything else is 400 INVALID_ARGUMENT with the message <name> "<value>" must be a boolean.
  • Timeouts. A connection that waits --http-idle-timeout (default 60s) for a request, has writes stuck that long, or stalls an upload that long is closed. Over HTTP/2, a connection with no request open that receives nothing but keepalive pings for that long is closed too.
  • Query strings are parsed as Go’s url.ParseQuery parses them: a parameter with a malformed % escape or a ; is dropped, and the first of repeated parameters counts.

GET /v1/health

Readiness. Never needs the token. Accepts GET and HEAD.
application/json
uptime_seconds counts from daemon start.
application/json
While shutting down: {"code":"UNAVAILABLE","message":"sandboxd is shutting down"}.

GET /v1/metadata

Environment variables of the daemon whose names start with --metadata-env-prefix (default SANDBOX_). axed leaves out names containing TOKEN, SECRET, PASSWORD, PASSWD, CRED, KEY, AUTH, BEARER, PRIVATE or CERT, in any case. Accepts GET and HEAD.
application/json

/v1/files/{path}

{path} is everything after /v1/files/, percent-decoded. /v1/files and /v1/files/ name the root. A path that is not valid UTF-8 after decoding is 400. Paths resolve inside --root-dir. axed strips the root from an absolute path under the root, takes any other absolute path relative to the root, and cleans . and .. lexically. A path that climbs above the root is 403 PERMISSION_DENIED. axed follows symlinks only while they stay inside the root. Methods: GET, HEAD, PUT, DELETE, POST.

File metadata

stat=true and directory listings return entries with these fields:

GET: download, list or stat

file | directory
Require the path to be this kind. A mismatch is 409 CONFLICT (path is a directory, not a file or path is a file, not a directory). Any other value is 400.
boolean
Return the path’s metadata as one JSON entry instead of its contents.
boolean
List a directory recursively instead of its direct children.
positive integer
With recursive, how deep to list: 1 is direct children. Unlimited when absent. Has no effect without recursive, but axed still validates it. Zero, negative or non-numeric values are 400.
A file streams as 200 with Content-Type: application/octet-stream, Content-Length, Accept-Ranges: bytes and Last-Modified. Conditional and range requests follow Go’s http.ServeContent: Dates compare at one-second granularity, as Last-Modified carries no fraction. A file modified exactly at the Unix epoch counts as having no known modification time: it gets no Last-Modified, and If-Modified-Since and If-Unmodified-Since are ignored. HEAD returns the same headers without a body. A directory returns 200 with a listing. Without recursive it lists direct children. Entries are in lexical order, each directory before its contents. Symlinks show their target’s metadata and are never descended into; broken symlinks and ones that point outside the root are left out. A recursive listing deeper than one level that passes 10,000 entries is 400; limit the depth or list a subdirectory. A listing of direct children is 400 only when the directory holds more than 1,048,576 entries. Any listing is 400 once the names it returns, each a path from the listed directory, add up to more than 32 MiB.
path is the request path with a leading /.

PUT: upload, make a directory, or extract

The body is the file’s contents: raw, or the part named file of a multipart/form-data body (other parts are skipped). There is no size limit. On success, every form returns 204.
file | directory
directory creates a directory instead of uploading. file makes a directory at the path a 409 instead of a 400.
string
Permission bits as exactly four octal digits starting with 0, matching ^0[0-7]{3}$, for example 0600. axed applies it exactly and ignores the umask. Default 0644 for files, 0755 for directories and for extract.
boolean
Append to the file, creating it if needed, instead of replacing it. Not atomic.
boolean
With type=directory, create missing parents.
tar
Unpack the body, a tar or gzipped tar archive, into the directory at {path}, creating it. Entries may not escape the directory, even through symlinks the archive creates. At most 100,000 entries and 1 GiB of file data, and at most 32 KiB of header, long-name, long-link and PAX records for any one entry. Setuid and setgid bits are dropped from extracted modes. Cannot be combined with append, type or If-None-Match.
*
Create only: fail with 412 FAILED_PRECONDITION (path already exists) if anything exists at the path. Only * is accepted; any other value is 400. Not allowed with type=directory. With append, append is ignored and the upload is create-only.
axed writes a regular upload to an unnamed O_TMPFILE (a .axe-tmp-* file on filesystems without it) and links it into place when the body is complete, so the path never holds a partial file, watchers never report the temporary file, and a failed upload leaves nothing. axed creates missing parent directories. An existing directory with type=directory succeeds unchanged.

DELETE

boolean
Delete a directory and its contents. Deleting the root with recursive empties it.
Deletes a file, a symlink (never its target) or a directory. axed validates parameters before it touches the filesystem.

POST: move or copy

Moves or copies the file, symlink or directory tree at {path}. Symlinks are transferred as links.
path
required
Where it goes. Missing or empty is 400 (destination is required).
boolean
Replace an existing file. Never replaces a directory.

Examples

process.v1.ProcessService

As in sandboxd, processes that a command leaves running when it exits on its own, such as server &, keep running after Start or Execute returns. They die with the command when the client disconnects from Start first, when a time limit kills it, and when axed shuts down with cgroups. Once the command exits, axed waits up to 5 seconds for output that they keep open, then reports the exit. Process ids in this API are integers (int32), not axe.v1’s 32-hex-digit string ids. The adapter gives each process started through Start the next unused number, from 1, and reports it in the stream’s init event. WriteStdin, SendSignal and ResizeTTY find a process by that number while axed tracks it, and answer NOT_FOUND otherwise. Processes started through axe.v1 or ateenv, and Execute runs, take no number.

Start

Runs a command and streams its output. If the client cancels or disconnects before the process exits, axed kills the process tree. axed forgets the process when it exits, so its id is unknown afterwards. StartResponse events, in order: The reader is lossless. A slow client holds the process back once retention is full.

Execute

Runs a command to completion and returns exit_code, stdout and stderr. The time and byte limits are the deployment defaults (--execute-default-*, or the maximums when no default is set). axed caps output at 256 MiB per stream even with no limit configured. axed kills the process tree if the call is cancelled.

ExecuteWithLimits

Runs a command with bounded output and reports the outcome instead of failing.

WriteStdin

Writes input bytes to the process’s stdin, or closes it with eof. An empty payload does nothing. Output in response arrives on the Start stream. A second eof succeeds and does nothing.

SendSignal

Sends SIGNAL_SIGINT, SIGNAL_SIGTERM or SIGNAL_SIGKILL to the process group. SIGNAL_UNSPECIFIED or any other value is INVALID_ARGUMENT. An unknown process is NOT_FOUND.

ResizeTTY

Sets the PTY size to cols by rows. Fails with FAILED_PRECONDITION (failed to resize TTY: ...) when the process has no PTY or has exited. An unknown process is NOT_FOUND.

watcher.v1.FileWatcherService

WatchDir

Streams changes under a directory. FileEvent has type, path (relative to the root) and error: axed batches events in 250 ms windows and delivers them in order. It detects removal of the watched directory from the directory’s own inotify events, not by watching its parent. It does not report temporary files from in-progress uploads. The stream ends when the client disconnects, after a terminal error, or when axed shuts down.