> ## Documentation Index
> Fetch the complete documentation index at: https://docs.akua.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Kubernetes access

> Give AI agents direct access to cluster resources through the Kubernetes API proxy and command execution

<Frame>
  <img className="block dark:hidden" src="https://mintcdn.com/akua-1dce587a/3H5lVc027NQakOso/images/heros/kubernetes-access-light.svg?fit=max&auto=format&n=3H5lVc027NQakOso&q=85&s=e2e3d73e73ead982791e24b82a8a9189" alt="An agent request passes a guard that injects auth, checks workspace membership, and bounds each call, then forks into the kube API proxy reaching cluster resources and the exec endpoint running a command inside a pod" width="1536" height="864" data-path="images/heros/kubernetes-access-light.svg" />

  <img className="hidden dark:block" src="https://mintcdn.com/akua-1dce587a/3H5lVc027NQakOso/images/heros/kubernetes-access-dark.svg?fit=max&auto=format&n=3H5lVc027NQakOso&q=85&s=d0b6f6569c122f0134019c54359a9231" alt="An agent request passes a guard that injects auth, checks workspace membership, and bounds each call, then forks into the kube API proxy reaching cluster resources and the exec endpoint running a command inside a pod" width="1536" height="864" data-path="images/heros/kubernetes-access-dark.svg" />
</Frame>

The platform MCP server includes a transparent Kubernetes API proxy and a command execution endpoint. Together, they let agents read pod logs, list resources, inspect deployments, discover <Tooltip headline="Custom Resource Definitions" tip="CRDs are user-defined extensions to the Kubernetes API that let operators add custom resource types to a cluster.">CRDs</Tooltip>, and run commands, all through the same `platform.request()` interface.

<Info>
  These endpoints are accessed through the [Platform MCP](/ai/platform-mcp) server's `execute` tool. The agent writes JavaScript that calls `platform.request()`.
</Info>

## Kube API proxy

`GET /v1/clusters/{id}/kube_proxy/{path}` proxies any request to the cluster's Kubernetes API server. The path after `/kube_proxy/` is forwarded directly, along with query parameters.

### Pod logs

Fetch pod logs as plain text:

```js theme={null}
async () => {
  const res = await platform.request({
    method: "GET",
    path: "/v1/clusters/CLUSTER_ID/kube_proxy/api/v1/namespaces/NAMESPACE/pods/POD_NAME/log",
    query: { tailLines: "100" }
  });
  return res.body;
}
```

### List resources

List pods, deployments, configmaps, services, or any Kubernetes resource:

```js theme={null}
async () => {
  // List pods in a namespace
  const res = await platform.request({
    method: "GET",
    path: "/v1/clusters/CLUSTER_ID/kube_proxy/api/v1/namespaces/default/pods"
  });
  return res.body.items.map(p => ({
    name: p.metadata.name,
    status: p.status.phase
  }));
}
```

```js theme={null}
async () => {
  // List deployments
  const res = await platform.request({
    method: "GET",
    path: "/v1/clusters/CLUSTER_ID/kube_proxy/apis/apps/v1/namespaces/default/deployments"
  });
  return res.body.items.map(d => ({
    name: d.metadata.name,
    replicas: d.status.readyReplicas + "/" + d.spec.replicas
  }));
}
```

### API discovery

Agents can discover cluster-specific APIs (including CRDs) by fetching the Kubernetes OpenAPI spec:

```
GET /v1/clusters/{id}/kube_proxy/openapi/v3
```

This is useful when the agent needs to work with custom resources it hasn't seen before. It can inspect the spec, find the right API group and version, then make calls.

### Supported methods

The proxy supports all HTTP methods (`GET`, `POST`, `PUT`, `PATCH`, `DELETE`), so agents can also create and modify resources when needed.

## Command execution

`POST /v1/clusters/{id}:exec` runs a command in a pod container and returns the combined output:

```js theme={null}
async () => {
  const res = await platform.request({
    method: "POST",
    path: "/v1/clusters/CLUSTER_ID:exec",
    body: {
      namespace: "default",
      pod: "postgres-0",
      container: "postgresql",
      command: ["psql", "-c", "SELECT version();"]
    }
  });
  return res.body;
  // { output: "PostgreSQL 16.1 ...\n", exit_code: 0, duration_ms: 142 }
}
```

### Request body

| Field       | Type       | Required | Description                   |
| ----------- | ---------- | -------- | ----------------------------- |
| `namespace` | `string`   | Yes      | Kubernetes namespace          |
| `pod`       | `string`   | Yes      | Pod name                      |
| `container` | `string`   | No       | Container name within the pod |
| `command`   | `string[]` | Yes      | Command and arguments         |

### Response

| Field         | Type      | Description                                 |
| ------------- | --------- | ------------------------------------------- |
| `output`      | `string`  | Combined command output (stdout and stderr) |
| `exit_code`   | `integer` | Exit code (`0` = success)                   |
| `duration_ms` | `number`  | Execution time in milliseconds              |

<Note>
  Exec is non-interactive (no TTY, no stdin) with a 30-second timeout. For interactive shells, use the dashboard terminal.
</Note>

## Security

* **Authentication** is handled server-side. Agents cannot read or set the `Authorization` header.
* **Authorization** checks workspace membership before proxying any request.
* All code runs in a **sandboxed V8 isolate** with no access to the filesystem, network, or Node.js APIs.
* The kube proxy has a **30-second timeout** per request.
* Exec commands have a **30-second timeout** and are non-interactive.

## Related topics

<CardGroup cols={2}>
  <Card title="Code Mode in action" icon="bolt" href="/ai/code-mode-in-action">
    See how agents compose complex operations in a single call.
  </Card>

  <Card title="Platform MCP" icon="server" href="/ai/platform-mcp">
    The MCP server that provides these endpoints.
  </Card>

  <Card title="CRD discovery" icon="magnifying-glass-chart" href="/ai/examples/crd-discovery">
    Discover and interact with custom Kubernetes resources.
  </Card>

  <Card title="Incident debugging" icon="bug" href="/ai/examples/incident-debugging">
    Full SRE triage using pod health, events, logs, and rollout history.
  </Card>
</CardGroup>
