API: K3s Clusters

REST API endpoints for Kubernetes cluster management.

API: K3s Clusters

Endpoints

MethodPathDescription
POST/v1/k3sCreate a K3s cluster
GET/v1/k3sList all clusters
GET/v1/k3s/{id}Get cluster details
DELETE/v1/k3s/{id}Delete a cluster
## Create Cluster
POST /v1/k3s

Request Body

{
  "metadata": {
    "name": "production-k3s",
    "labels": {"env": "production"}
  },
  "spec": {
    "version": "1.28",
    "master_count": 3,
    "worker_count": 5,
    "pod_cidr": "10.42.0.0/16",
    "service_cidr": "10.43.0.0/16"
  }
}

Response (201)

{
  "id": "k3s-a1b2c3",
  "metadata": {
    "name": "production-k3s",
    "labels": {"env": "production"},
    "created_at": "2025-01-15T10:30:00Z"
  },
  "spec": {
    "version": "1.28",
    "master_count": 3,
    "worker_count": 5,
    "pod_cidr": "10.42.0.0/16",
    "service_cidr": "10.43.0.0/16"
  },
  "status": {
    "state": "provisioning",
    "api_endpoint": "",
    "node_count": 0,
    "ready_nodes": 0
  },
  "operation_id": "op-k3s-001"
}

K3sClusterSpec Fields

FieldTypeRequiredDescription
versionstringNoK3s version (default: latest stable)
master_countintNoControl plane nodes (default: 1, use 3 for HA)
worker_countintNoWorker nodes (default: 2)
pod_cidrstringNoPod network CIDR (default: 10.42.0.0/16)
service_cidrstringNoService network CIDR (default: 10.43.0.0/16)
## Get Cluster with Kubeconfig
GET /v1/k3s/k3s-a1b2c3?include=kubeconfig

Returns the cluster details with an additional kubeconfig field containing the YAML configuration for kubectl access.