# Kubernetes Management UI - Complete Feature Implementation Plan ## Project: tftsr-devops_investigation v1.1.0 ## Target: 100% Lens Desktop v5.x Feature Parity (MIT Licensed) ## Architecture: Tauri 2 + Rust Backend + React/TypeScript Frontend --- ## Executive Summary This plan implements a complete Lens Desktop v5.x-equivalent Kubernetes Management UI using the existing project architecture (Tauri + Rust + React). All features will be MIT-licensed, building on the foundation already established in the project. **Current Status (v1.1.0):** - ✅ 43 backend commands implemented in `src-tauri/src/commands/kube.rs` - ✅ 115 command wrappers in `src/lib/tauriCommands.ts` - ✅ Basic cluster management (add/remove/list) - ✅ Port forwarding (start/stop/delete/shutdown) - ✅ Resource discovery (pods, services, deployments, statefulsets, daemonsets, namespaces) - ✅ Resource management (scale, restart, delete, exec) - ✅ 22 additional resource types via backend commands - ✅ Frontend components for 10 resource types (ClusterList, PodList, ServiceList, DeploymentList, StatefulSetList, DaemonSetList, PortForwardList, AddClusterModal, PortForwardForm, ResourceBrowser) **What's Missing:** - Frontend UI components for remaining 10+ resource types (Nodes, Events, ConfigMaps, Secrets, ReplicaSets, Jobs, CronJobs, Ingresses, PVCs, PVs, ServiceAccounts, Roles, ClusterRoles, RoleBindings, ClusterRoleBindings, HPAs) - Advanced features (terminal, YAML editor, metrics, search, context switcher) - Real-time updates via Kubernetes API watchers - Multi-cluster context switching UI - Application grouping --- ## Phase 1: Complete Resource Discovery UI (Priority: HIGH) ### 1.1 Nodes View **File:** `src/components/Kubernetes/NodeList.tsx` **Features:** - Table view of all cluster nodes - Node status (Ready/NotReady) - Roles (control-plane, worker) - Kubernetes version - Internal/external IPs - OS image, kernel version, kubelet version - Age - Actions: Cordon, Uncordon, Drain, Shell, Edit, Delete **Backend Commands (✅ Implemented):** - `list_nodes()` - List all nodes - `cordon_node()` - Mark node as unschedulable - `uncordon_node()` - Mark node as schedulable - `drain_node()` - Evict pods from node ### 1.2 Events View **File:** `src/components/Kubernetes/EventList.tsx` **Features:** - Table view of cluster events - Event type (Normal/Warning) - Reason (PodScheduled, Pulling, etc.) - Object (pod name, deployment name) - Count - First seen, last seen - Message - Filter by namespace **Backend Commands (✅ Implemented):** - `list_events()` - List all events ### 1.3 ConfigMaps View **File:** `src/components/Kubernetes/ConfigMapList.tsx` **Features:** - Table view of configmaps - Data keys count - Age - View/edit configmap data - Delete configmap **Backend Commands (✅ Implemented):** - `list_configmaps()` - List all configmaps - `create_resource()` - Create resource from YAML - `edit_resource()` - Edit resource via YAML - `delete_resource()` - Delete resource ### 1.4 Secrets View **File:** `src/components/Kubernetes/SecretList.tsx` **Features:** - Table view of secrets - Secret type (Opaque, TLS, etc.) - Data keys count - Age - Masked values (show ***) - View/edit secret (YAML or form) - Delete secret **Backend Commands (✅ Implemented):** - `list_secrets()` - List all secrets ### 1.5 ReplicaSets View **File:** `src/components/Kubernetes/ReplicaSetList.tsx` **Features:** - Table view of replica sets - Desired/Ready replicas - Age - Labels - Actions: View details, Delete **Backend Commands (✅ Implemented):** - `list_replicasets()` - List all replica sets ### 1.6 Jobs View **File:** `src/components/Kubernetes/JobList.tsx` **Features:** - Table view of jobs - Completions (e.g., 1/1) - Duration - Age - Status (Active/Succeeded/Failed) - Actions: View logs, Delete **Backend Commands (✅ Implemented):** - `list_jobs()` - List all jobs ### 1.7 CronJobs View **File:** `src/components/Kubernetes/CronJobList.tsx` **Features:** - Table view of cronjobs - Schedule (e.g., 0 * * * *) - Active jobs count - Last schedule - Age - Actions: View details, Delete **Backend Commands (✅ Implemented):** - `list_cronjobs()` - List all cronjobs ### 1.8 Ingresses View **File:** `src/components/Kubernetes/IngressList.tsx` **Features:** - Table view of ingresses - Class (nginx, traefik, etc.) - Host (domain) - Addresses (load balancer IPs) - Age - Actions: View details, Delete **Backend Commands (✅ Implemented):** - `list_ingresses()` - List all ingresses ### 1.9 PersistentVolumeClaims View **File:** `src/components/Kubernetes/PVCList.tsx` **Features:** - Table view of PVCs - Status (Pending/Bound/Lost) - Volume (bound PV name) - Capacity - Access modes (RWO, ROX, etc.) - Age - Actions: Delete **Backend Commands (✅ Implemented):** - `list_persistentvolumeclaims()` - List all PVCs ### 1.10 PersistentVolumes View **File:** `src/components/Kubernetes/PVList.tsx` **Features:** - Table view of PVs - Status (Available/Bound/Released/Failed) - Capacity - Access modes - Reclaim policy (Retain/Recycle/Delete) - Storage class - Age - Actions: Delete **Backend Commands (✅ Implemented):** - `list_persistentvolumes()` - List all PVs ### 1.11 ServiceAccounts View **File:** `src/components/Kubernetes/ServiceAccountList.tsx` **Features:** - Table view of service accounts - Secrets count - Age - Actions: View details, Delete **Backend Commands (✅ Implemented):** - `list_serviceaccounts()` - List all service accounts ### 1.12 Roles View **File:** `src/components/Kubernetes/RoleList.tsx` **Features:** - Table view of roles - Namespace - Age - Actions: View rules, Delete **Backend Commands (✅ Implemented):** - `list_roles()` - List all roles ### 1.13 ClusterRoles View **File:** `src/components/Kubernetes/ClusterRoleList.tsx` **Features:** - Table view of cluster roles - Age - Actions: View rules, Delete **Backend Commands (✅ Implemented):** - `list_clusterroles()` - List all cluster roles ### 1.14 RoleBindings View **File:** `src/components/Kubernetes/RoleBindingList.tsx` **Features:** - Table view of role bindings - Namespace - Role (reference) - Age - Actions: View details, Delete **Backend Commands (✅ Implemented):** - `list_rolebindings()` - List all role bindings ### 1.15 ClusterRoleBindings View **File:** `src/components/Kubernetes/ClusterRoleBindingList.tsx` **Features:** - Table view of cluster role bindings - Cluster role (reference) - Age - Actions: View details, Delete **Backend Commands (✅ Implemented):** - `list_clusterrolebindings()` - List all cluster role bindings ### 1.16 HorizontalPodAutoscalers View **File:** `src/components/Kubernetes/HPAList.tsx` **Features:** - Table view of HPAs - Min/Max replicas - Current replicas - Desired replicas - Age - Actions: View details, Delete **Backend Commands (✅ Implemented):** - `list_horizontalpodautoscalers()` - List all HPAs --- ## Phase 2: Advanced Features (Priority: HIGH) ### 2.1 Interactive Terminal **File:** `src/components/Kubernetes/Terminal.tsx` **Features:** - Full-featured terminal using xterm.js - Multiple tabs support - Shell selection (sh, bash, zsh) - Multi-container pod support - Resize support - Copy/paste - Search in output - Clear screen - Disconnect/reconnect **Backend Commands (✅ Implemented):** - `exec_pod()` - Execute command in pod **Implementation Notes:** - Use `xterm.js` for terminal rendering - Use `xterm-addon-web-links` for link detection - Use `xterm-addon-fit` for auto-resize - WebSocket-based terminal session (or kubectl exec) ### 2.2 YAML Editor **File:** `src/components/Kubernetes/YamlEditor.tsx` **Features:** - Code editor using Monaco (VS Code's editor) - Syntax highlighting for YAML - Validation (basic schema validation) - Diff view (before/after) - Apply button - Cancel button - Error messages **Dependencies:** - `@monaco-editor/react` (MIT licensed) ### 2.3 Metrics Visualization **File:** `src/components/Kubernetes/MetricsChart.tsx` **Features:** - CPU usage chart (line/bar) - Memory usage chart - Time range selector (5m, 15m, 1h, 6h, 1d, 7d) - Zoom functionality - Legend - Tooltip with values - Per-container metrics for pods **Backend Commands:** - Need to add: `get_metrics()` for node/pod metrics **Dependencies:** - `react-chartjs-2` or `recharts` (MIT licensed) ### 2.4 Search and Filter **File:** `src/components/Kubernetes/SearchBar.tsx` **Features:** - Global search bar - Search by name, labels, annotations - Filter by namespace - Filter by status - Filter by resource type - Recent searches - Search suggestions **Implementation Notes:** - Debounced search - Client-side filtering (or server-side for large datasets) - Keyboard shortcuts (Ctrl+K) ### 2.5 Application Grouping **File:** `src/components/Kubernetes/ApplicationView.tsx` **Features:** - Group workloads by application label - Visual hierarchy (app → deployment → pods) - Resource relationships - Dependency visualization - Application status summary **Implementation Notes:** - Tree view component - Use labels to group resources - Show owner references ### 2.6 Context Switcher **File:** `src/components/Kubernetes/ContextSwitcher.tsx` **Features:** - Current cluster display - Cluster selector dropdown - Context selector (when multiple contexts in kubeconfig) - Quick switch between clusters - Visual indicator of active cluster **Backend Commands (✅ Implemented):** - `list_clusters()` - List all clusters - `add_cluster()` - Add cluster - `remove_cluster()` - Remove cluster --- ## Phase 3: Enhanced Workloads (Priority: HIGH) ### 3.1 Enhanced Pod List **File:** `src/components/Kubernetes/PodList.tsx` (Update) **Add Features:** - Multi-container pod support (select container) - Container status indicators - Resource requests/limits display - Node assignment - IP address - Restart count - Events tab - Logs streaming (auto-refresh) ### 3.2 Enhanced Deployment List **File:** `src/components/Kubernetes/DeploymentList.tsx` (Update) **Add Features:** - Rollout status - Revision history - Rollback button - Update strategy - Progress conditions - Events tab **Backend Commands (✅ Implemented):** - `rollback_deployment()` - Rollback deployment ### 3.3 Enhanced Service List **File:** `src/components/Kubernetes/ServiceList.tsx` (Update) **Add Features:** - Endpoints display - Selector display - Session affinity - Type-specific fields (LoadBalancer IPs, NodePorts) - External name display - Events tab ### 3.4 Enhanced ConfigMap/Secret View **File:** `src/components/Kubernetes/ConfigMapDetail.tsx` **Features:** - Data keys as expandable list - Key-value pairs display - Edit mode (form or YAML) - Create new key - Delete key - Export to file --- ## Phase 4: Cluster Management (Priority: MEDIUM) ### 4.1 Cluster Overview **File:** `src/components/Kubernetes/ClusterOverview.tsx` **Features:** - Cluster name and version - API server URL - Provider information - Node count (total, ready) - Resource utilization (CPU, memory) - Workload counts - Quick actions (add cluster, refresh) **Backend Commands:** - `list_nodes()` - ✅ Implemented - Need to add: `get_cluster_info()` ### 4.2 Cluster Details **File:** `src/components/Kubernetes/ClusterDetails.tsx` **Features:** - Cluster configuration - Certificate details - Storage classes - Network policies - RBAC summary - Add-ons --- ## Phase 5: User Experience (Priority: MEDIUM) ### 5.1 Hotbar (Quick Actions) **File:** `src/components/Kubernetes/Hotbar.tsx` **Features:** - Quick access toolbar - Common actions (refresh, create, search) - Recent actions - Custom shortcuts ### 5.2 Command Palette **File:** `src/components/Kubernetes/CommandPalette.tsx` **Features:** - Quick command access (Ctrl+Shift+P) - Command search - Keyboard shortcuts - Recent commands ### 5.3 Toast Notifications **File:** `src/components/Kubernetes/Toast.tsx` **Features:** - Success/error notifications - Auto-dismiss - Action buttons in notifications - History of notifications ### 5.4 Loading States **File:** `src/components/Kubernetes/LoadingSpinner.tsx` **Features:** - Loading indicators for all async operations - Skeleton screens for data tables - Progress indicators --- ## Phase 6: Advanced Management (Priority: LOW) ### 6.1 Resource Creation Dialogs **File:** `src/components/Kubernetes/CreateResourceModal.tsx` **Features:** - Create from template - Create from YAML - Create from form - Namespace selection - Validation - Apply button ### 6.2 Resource Edit Dialog **File:** `src/components/Kubernetes/EditResourceModal.tsx` **Features:** - Edit existing resource - YAML editor - Form editor - Preview changes - Apply button ### 6.3 Port Forward UI **File:** `src/components/Kubernetes/PortForwardForm.tsx` (Update) **Add Features:** - Pod selector - Container selector - Local port auto-detection - Target port selection - Multiple port forwards - Active forwards list **Backend Commands (✅ Implemented):** - `start_port_forward()` - ✅ Implemented - `stop_port_forward()` - ✅ Implemented - `list_port_forwards()` - ✅ Implemented ### 6.4 Helm Integration **File:** `src/components/Kubernetes/HelmView.tsx` **Features:** - Charts view (from repositories) - Releases view - Install chart - Upgrade release - Rollback release - Uninstall release **Backend Commands:** - Need to add: `helm_*` commands --- ## Phase 7: Real-time Updates (Priority: HIGH) ### 7.1 WebSocket Watchers **File:** `src-tauri/src/kube/watcher.rs` **Features:** - Kubernetes API watchers for all resource types - Reconnect logic - Resource caching with diff updates - Real-time UI updates - Performance optimization **Implementation Notes:** - Use `k8s-openapi` crate with `watch` feature - Implement per-resource-type watchers - Cache resources locally - Push updates to frontend via Tauri events ### 7.2 Event Bus **File:** `src/lib/eventBus.ts` **Features:** - Centralized event system - Resource change events - Connection status events - Error events --- ## Phase 8: RBAC Management (Priority: MEDIUM) ### 8.1 RBAC Viewer **File:** `src/components/Kubernetes/RbacViewer.tsx` **Features:** - Role bindings visualization - Reverse lookup (who has access to what) - Permission checker - Simulate policy ### 8.2 RBAC Editor **File:** `src/components/Kubernetes/RbacEditor.tsx` **Features:** - Create/edit roles - Add/remove rules - Bind roles to subjects - Preview permissions --- ## Phase 9: Extension System (Priority: LOW) ### 9.1 Extension API **File:** `src/lib/extensions.ts` **Features:** - Plugin architecture - Extension loading - Extension management UI - Sandbox environment **Implementation Notes:** - Use WebAssembly for extensions - Or use Node.js child processes - Define extension API surface --- ## Implementation Order ### Sprint 1 (Week 1): Resource Discovery UI - Nodes, Events, ConfigMaps, Secrets - ReplicaSets, Jobs, CronJobs - Ingresses, PVCs, PVs - ServiceAccounts, Roles, ClusterRoles - RoleBindings, ClusterRoleBindings, HPAs ### Sprint 2 (Week 2): Advanced Features - Interactive terminal - YAML editor - Metrics visualization - Search and filter - Application grouping - Context switcher ### Sprint 3 (Week 3): Enhanced Workloads - Enhanced Pod/Deployment/Service lists - ConfigMap/Secret detail views - Cluster overview - Cluster details ### Sprint 4 (Week 4): UX & Polish - Hotbar, Command palette - Toast notifications - Loading states - Resource creation/edit dialogs - Port forward UI ### Sprint 5 (Week 5): Real-time & RBAC - WebSocket watchers - Event bus - RBAC viewer/editor - Extension system (optional) ### Sprint 6 (Week 6): Testing & Release - Test coverage - Documentation - Bug fixes - Release preparation --- ## Dependencies to Add ### Frontend (npm): ```json { "xterm": "^5.3.0", "xterm-addon-web-links": "^0.9.0", "xterm-addon-fit": "^0.8.0", "@monaco-editor/react": "^4.6.0", "react-chartjs-2": "^5.2.0", "chart.js": "^4.4.0", "zustand": "^4.4.0" (already present) } ``` ### Backend (Cargo.toml): ```toml # For Kubernetes API watchers k8s-openapi = { version = "0.21", features = ["watch"] } tokio-stream = "1.0" ``` --- ## Architecture Updates ### State Management - Add `clusters` store (persisted) - Add `portForwards` store (persisted) - Add `selectedContext` store (ephemeral) - Add `resources` store (cached, with watchers) ### Backend Enhancements - Add `ResourceCache` struct for efficient local caching - Add `ResourceWatcher` for Kubernetes API watchers - Add `EventBus` for real-time updates - Add `MetricsCollector` for resource metrics --- ## Success Criteria ✅ **100% Feature Parity Checklist:** ### Core Features (Must Have) - [ ] All 16 resource discovery UIs implemented - [ ] All 6 management UIs implemented - [ ] Interactive terminal with tab support - [ ] YAML editor with validation - [ ] Metrics visualization - [ ] Search and filter functionality - [ ] Application grouping - [ ] Context switcher - [ ] Real-time updates via watchers - [ ] RBAC viewer/editor ### Quality Features (Should Have) - [ ] Hotbar and command palette - [ ] Toast notifications - [ ] Loading states - [ ] Resource creation/edit dialogs - [ ] Port forward UI - [ ] Helm integration - [ ] Cluster overview - [ ] RBAC management ### Enterprise Features (Nice to Have) - [ ] Extension system - [ ] Multi-cluster management UI - [ ] Team sharing - [ ] Audit trail enhancements --- ## Risk Assessment | Risk | Impact | Mitigation | |------|--------|------------| | Backend command implementation | HIGH | Already done (43 commands) | | Frontend component complexity | MEDIUM | Use existing patterns | | Real-time performance | MEDIUM | Implement caching and diff updates | | Terminal integration | LOW | Use xterm.js library | | Metrics collection | MEDIUM | Add `get_metrics()` command | | Helm integration | LOW | Optional feature | --- ## Notes - All implementations must remain MIT licensed - Follow existing code patterns in the project - Use existing UI components from `src/components/ui/index.tsx` - Test each feature before moving to next - Update `RELEASE_NOTES.md` for each phase - Update `README.md` with new features --- **Document Version:** 1.0 **Last Updated:** 2026-06-07 **Next Review:** After Sprint 1 completion