feat: add phase 1 fastapi backend and frontend

Co-authored-by: aider (openrouter/thinkingmachines/inkling-small:free) <aider@aider.chat>
This commit is contained in:
Jiří Stachandaider committed 2026-10-09 15:23:11 +02:00
1 parent e67d1f3316
commit 82a0839004
6 files changed
+189 -1

No files matched your search

+52
View File
@@ -0,0 +1,52 @@
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
import subprocess
app = FastAPI()
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
@app.get("/")
def root():
return {"message": "Kubectl Web GUI backend"}
@app.get("/contexts")
def get_contexts():
result = subprocess.run(
["kubectl", "config", "get-contexts", "-o", "name"],
capture_output=True, text=True
)
contexts = [line for line in result.stdout.splitlines() if line]
current = ""
try:
cur = subprocess.run(
["kubectl", "config", "current-context"],
capture_output=True, text=True
)
current = cur.stdout.strip()
except Exception:
pass
return {"current": current, "contexts": contexts}
@app.get("/namespaces")
def get_namespaces():
result = subprocess.run(
["kubectl", "get", "namespaces", "-o", "jsonpath={range .items[*]}{.metadata.name}{\"\\n\"}{end}"],
capture_output=True, text=True
)
namespaces = [line for line in result.stdout.splitlines() if line]
return {"namespaces": namespaces}
@app.get("/pods")
def get_pods(namespace: str = "default"):
result = subprocess.run(
["kubectl", "get", "pods", "-n", namespace, "-o", "json"],
capture_output=True, text=True
)
return {"raw": result.stdout, "namespace": namespace}
+3
View File
@@ -0,0 +1,3 @@
fastapi
uvicorn[standard]
python-multipart