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

# REST API endpoints for Kubernetes clusters

> Register Kubernetes clusters, list namespaces, deployments, pods and services, and trigger security and drift scans via the InfraAudit API.

The Kubernetes endpoints let you register clusters, list namespaces, deployments, pods, and services, and remove clusters from InfraAudit. Clusters are registered by providing a kubeconfig, and InfraAudit continuously syncs their workloads.

Base path: `/api/v1/kubernetes`

***

## POST /kubernetes/clusters — register a cluster

Registers a new Kubernetes cluster using its kubeconfig.

```http theme={null}
POST /api/v1/kubernetes/clusters
Authorization: Bearer <token>
Content-Type: application/json
```

### Request body

<ParamField body="name" type="string" required>
  A human-readable label for this cluster, for example `Production EKS`.
</ParamField>

<ParamField body="kubeconfig" type="string" required>
  The kubeconfig YAML contents as a string.
</ParamField>

```json theme={null}
{
  "name": "Production EKS",
  "kubeconfig": "apiVersion: v1\nkind: Config\n..."
}
```

### Response `201`

```json theme={null}
{
  "id": 1,
  "name": "Production EKS",
  "status": "syncing",
  "created_at": "2024-01-15T10:00:00Z"
}
```

***

## GET /kubernetes/clusters — list clusters

Returns all registered clusters.

```http theme={null}
GET /api/v1/kubernetes/clusters
Authorization: Bearer <token>
```

***

## GET /kubernetes/clusters/{id} — get cluster

Returns details for a single cluster.

```http theme={null}
GET /api/v1/kubernetes/clusters/{id}
Authorization: Bearer <token>
```

***

## GET /kubernetes/clusters/{id}/namespaces — list namespaces

```http theme={null}
GET /api/v1/kubernetes/clusters/{id}/namespaces
Authorization: Bearer <token>
```

***

## GET /kubernetes/clusters/{id}/deployments — list deployments

```http theme={null}
GET /api/v1/kubernetes/clusters/{id}/deployments
Authorization: Bearer <token>
```

### Query parameters

<ParamField query="namespace" type="string">
  Filter by namespace.
</ParamField>

### Response

```json theme={null}
[
  {
    "name": "api-deployment",
    "namespace": "production",
    "replicas": 3,
    "ready_replicas": 3,
    "image": "myapp:1.24.0"
  }
]
```

***

## GET /kubernetes/clusters/{id}/pods — list pods

```http theme={null}
GET /api/v1/kubernetes/clusters/{id}/pods
Authorization: Bearer <token>
```

### Query parameters

<ParamField query="namespace" type="string">
  Filter by namespace.
</ParamField>

***

## GET /kubernetes/clusters/{id}/services — list services

```http theme={null}
GET /api/v1/kubernetes/clusters/{id}/services
Authorization: Bearer <token>
```

***

## DELETE /kubernetes/clusters/{id} — remove cluster

Removes the cluster registration and stops syncing. Historical data is retained.

```http theme={null}
DELETE /api/v1/kubernetes/clusters/{id}
Authorization: Bearer <token>
```

Returns `204 No Content`.
