Skip to content

Backend API ​

The backend is a single Express server (server.js) that provides both REST API endpoints and WebSocket connections.

Server Structure ​

js
server.js          // Main entry — Express app, K8s routes, WebSocket setup
routes/
├── aws.js         // AWS service endpoints
├── gcp.js         // GCP service endpoints
├── helm.js        // Helm repositories, chart search, install and releases
├── envManager.js  // Profile/credential management
├── localShell.js  // Local terminal WebSocket
└── systemTools.js // CLI tool detection

REST API Endpoints ​

Kubernetes ​

MethodPathDescription
GET/api/contextsList all kubeconfig contexts
POST/api/contextSwitch active context
DELETE/api/context/:nameDelete a context
GET/api/namespacesList namespaces
GET/api/:ns/podsList pods
GET/api/:ns/pods/:name/yamlGet pod YAML
DELETE/api/:ns/pods/:nameDelete pod
POST/api/:ns/deployments/:name/restartRestart deployment
POST/api/:ns/deployments/:name/scaleScale deployment
POST/api/kubeconfig/importImport kubeconfig YAML
POST/api/kubeconfig/pathRegister an existing kubeconfig file path
GET/api/:ns/:resource/:name/metricsMetrics for Pods and workloads with Prometheus fallback
GET/api/nodes/:name/metricsNode CPU/memory metrics
GET/api/events/relatedEvents related to a resource or Node
POST/api/nodes/:name/cordonCordon node
POST/api/nodes/:name/uncordonUncordon node
POST/api/nodes/:name/drainDrain node

Cloud Routes ​

PrefixModuleDescription
/api/cloud/awsroutes/aws.jsAWS services
/api/cloud/gcproutes/gcp.jsGCP services
/api/cloud/envsroutes/envManager.jsProfile management
/api/systemroutes/systemTools.jsCLI tool detection
/api/helmroutes/helm.jsHelm repositories, chart search, install, release inventory and uninstall

WebSocket Endpoints ​

PathPurpose
/ws/logsPod log streaming
/ws/execPod exec (interactive shell)
/ws/shellLocal system shell
/ws/ec2-shellEC2 instance shell (via SSH)

All WebSocket connections use noServer mode with manual upgrade routing to avoid conflicts between multiple WebSocket.Server instances.

Kubeconfig Management ​

The server merges kubeconfig files from multiple sources:

  1. KUBECONFIG env var paths
  2. Default ~/.kube/config
  3. UI-imported configs (~/.kube/kuadashboard_merged.yaml)
  4. Registered file paths (~/.kube/kuadashboard_paths.json)

Merging is non-destructive — existing entries are never overwritten.

Metrics Fallback ​

Kubernetes metrics first use the metrics.k8s.io/v1beta1 API. If Metrics Server is unavailable, KuaDashboard discovers Prometheus Services and queries them through the Kubernetes API server Service proxy, preserving the user's current kubeconfig and context.