Skip to content

Kubernetes API

API endpoints for Kubernetes cluster management.

Health

Get Cluster Health

GET /api/v1/kubernetes/health

Response:

{
  "status": "healthy",
  "nodes": {
    "total": 3,
    "ready": 3
  },
  "pods": {
    "total": 47,
    "running": 45,
    "pending": 1,
    "failed": 1
  }
}

Pods

List Pods

GET /api/v1/kubernetes/pods

Query Parameters: | Parameter | Type | Description | |-----------|------|-------------| | namespace | string | Filter by namespace | | label | string | Filter by label selector |

Response:

[
  {
    "name": "nginx-abc123",
    "namespace": "default",
    "status": "Running",
    "containers": ["nginx"],
    "ready_containers": 1,
    "total_containers": 1,
    "restarts": 0,
    "age": "2d",
    "node": "node-1"
  }
]

Get Pod Details

GET /api/v1/kubernetes/pods/{namespace}/{name}

Get Pod Logs

GET /api/v1/kubernetes/pods/{namespace}/{name}/logs

Query Parameters: | Parameter | Type | Description | |-----------|------|-------------| | container | string | Container name | | tail | int | Number of lines | | timestamps | bool | Include timestamps |

Delete Pod

DELETE /api/v1/kubernetes/pods/{namespace}/{name}

Deployments

List Deployments

GET /api/v1/kubernetes/deployments

Scale Deployment

POST /api/v1/kubernetes/scale

Request Body:

{
  "namespace": "default",
  "deployment": "nginx",
  "replicas": 5
}

Restart Deployment

POST /api/v1/kubernetes/restart

Request Body:

{
  "namespace": "default",
  "deployment": "nginx"
}

Services

List Services

GET /api/v1/kubernetes/services

Nodes

List Nodes

GET /api/v1/kubernetes/nodes

Get Node Details

GET /api/v1/kubernetes/nodes/{name}

Namespaces

List Namespaces

GET /api/v1/kubernetes/namespaces

Apply Manifest

Apply YAML

POST /api/v1/kubernetes/apply

Request Body:

{
  "yaml": "apiVersion: v1\nkind: Pod\n...",
  "namespace": "default",
  "dry_run": false
}

WebSocket Endpoints

Stream Logs

WS /api/v1/ws/pods/{namespace}/{pod}/logs

Query Parameters: - container - Container name - tail_lines - Initial lines (default: 100) - timestamps - Include timestamps

Messages:

{"type": "log", "content": "Log line here"}
{"type": "status", "status": "connected"}
{"type": "error", "error": "...", "code": 500}

Pod Exec

WS /api/v1/ws/pods/{namespace}/{pod}/exec

Query Parameters: - container - Container name - shell - Shell path (default: /bin/sh)

Client Messages:

{"type": "input", "data": "ls -la\n"}
{"type": "resize", "cols": 80, "rows": 24}

Server Messages:

{"type": "output", "data": "..."}
{"type": "status", "status": "connected"}