How benc-uk/kubeview works
Project type and purpose
• KubeView is a full-stack web application for visualizing Kubernetes clusters in real time.
• Backend is written in Go; frontend is a static HTML/JS app using Cytoscape.js for graph rendering, Alpine.js for interactivity, and Bulma for styling.
File structure
• Top-level directories:
• server/ – Go API server code (main.go, api.go, routes.go, config.go, sse.go) and services/ for Kubernetes client logic.
• public/ – static assets served to the browser: HTML fragments, CSS, JS modules (graph.js, main.js, side-panel.js, etc.), images.
• deploy/ – Dockerfile + Helm chart for Kubernetes deployment.
• .dev/ – development tool configs (linters, Prettier, Go tools).
• Config files: go.mod/go.sum, makefile, Dockerfile, Helm chart (Chart.yaml, templates), GitHub workflows.
README for additional insights
• REST endpoints (/api/*, /updates SSE, /health).
• Real-time updates via Server-Sent Events using a generated clientID.
• Two Kubernetes authentication modes: in-cluster (service account) or external kubeconfig.
• Helm chart includes service account, role, role binding.
a. Main components
• Web browser (client)
• Static asset server (Go server serving /public)
• API layer (Go HTTP router handling REST & SSE endpoints)
• SSE manager (per-client streams)
• Kubernetes API server (external system)
• Helm-deployed KubeView Pod + ServiceAccount (when in-cluster)
b. Relationships & interactions
• Browser loads index.html → fetches CSS/JS/HTML fragments.
• JS initializes: generates local clientID; requests /api/namespaces & /api/fetch; opens /updates SSE.
• Go API fetches data from Kubernetes API (via client-go), streams changes over SSE.
• Browser renders resource graph, listens for SSE updates to mutate the Cytoscape graph.
• User interactions trigger additional API calls (/api/logs, /api/status).
c. Architectural patterns
• Separation of concerns: static assets vs. API vs. streaming.
• Event-driven updates (SSE).
• Single binary Go server bundling frontend & API.
• Helm chart abstracts deployment concerns (RBAC, ingress, service).
d. Key technologies
• Go + client-go for backend
• HTML/CSS/ES6 JavaScript front end
• Cytoscape.js for graph visualization
• Alpine.js for UI bindings
• Bulma CSS framework
• Server-Sent Events for push notifications
• Helm & Docker for deployment