Lightweight Go-based dashboard for Raspberry Pi cluster: Backend: - chi router with REST API - Embedded static file serving - JSON file-based state storage - Health checks and CORS support Frontend: - Responsive dark theme UI - Status view with nodes, alerts, ArgoCD apps - Pending actions with approve/reject - Action history and audit trail - Workflow listing and manual triggers Deployment: - Multi-stage Dockerfile (small Alpine image) - Kubernetes manifests with Pi 3 tolerations - Resource limits: 32-64Mi memory, 10-100m CPU - ArgoCD application manifest - Kustomize configuration API endpoints: - GET /api/status - Cluster status - GET/POST /api/pending - Action management - GET /api/history - Action audit trail - GET/POST /api/workflows - Workflow management 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
81 lines
3.0 KiB
Go
81 lines
3.0 KiB
Go
package models
|
|
|
|
import "time"
|
|
|
|
// ClusterStatus represents the overall cluster health
|
|
type ClusterStatus struct {
|
|
Health string `json:"health"` // Healthy, Degraded, Critical
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
Nodes []NodeStatus `json:"nodes"`
|
|
Alerts []Alert `json:"alerts"`
|
|
Apps []AppStatus `json:"apps"`
|
|
}
|
|
|
|
// NodeStatus represents a single node's status
|
|
type NodeStatus struct {
|
|
Name string `json:"name"`
|
|
Status string `json:"status"` // Ready, NotReady
|
|
CPU float64 `json:"cpu_percent"`
|
|
Memory float64 `json:"memory_percent"`
|
|
Conditions string `json:"conditions"` // OK, MemoryPressure, DiskPressure, etc.
|
|
}
|
|
|
|
// Alert represents a Prometheus/Alertmanager alert
|
|
type Alert struct {
|
|
Name string `json:"name"`
|
|
Severity string `json:"severity"` // warning, critical
|
|
Description string `json:"description"`
|
|
FiringAt time.Time `json:"firing_at"`
|
|
}
|
|
|
|
// AppStatus represents an ArgoCD application status
|
|
type AppStatus struct {
|
|
Name string `json:"name"`
|
|
SyncStatus string `json:"sync_status"` // Synced, OutOfSync
|
|
Health string `json:"health"` // Healthy, Progressing, Degraded
|
|
Revision string `json:"revision"`
|
|
}
|
|
|
|
// PendingAction represents an action awaiting user approval
|
|
type PendingAction struct {
|
|
ID string `json:"id"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
Agent string `json:"agent"`
|
|
Action string `json:"action"`
|
|
Description string `json:"description"`
|
|
Details map[string]interface{} `json:"details"`
|
|
Risk string `json:"risk"` // low, medium, high
|
|
Workflow string `json:"workflow,omitempty"`
|
|
}
|
|
|
|
// ActionDecision represents the user's decision on a pending action
|
|
type ActionDecision struct {
|
|
ID string `json:"id"`
|
|
Decision string `json:"decision"` // approved, rejected
|
|
DecidedAt time.Time `json:"decided_at"`
|
|
DecidedBy string `json:"decided_by,omitempty"`
|
|
Reason string `json:"reason,omitempty"`
|
|
}
|
|
|
|
// ActionHistory represents a completed action
|
|
type ActionHistory struct {
|
|
ID string `json:"id"`
|
|
Timestamp time.Time `json:"timestamp"`
|
|
Agent string `json:"agent"`
|
|
Action string `json:"action"`
|
|
Description string `json:"description"`
|
|
Details map[string]interface{} `json:"details,omitempty"`
|
|
Result string `json:"result"` // success, failed
|
|
AutoApproved bool `json:"auto_approved"`
|
|
Workflow string `json:"workflow,omitempty"`
|
|
}
|
|
|
|
// Workflow represents a defined workflow
|
|
type Workflow struct {
|
|
Name string `json:"name"`
|
|
Description string `json:"description"`
|
|
Triggers []string `json:"triggers"`
|
|
LastRun *time.Time `json:"last_run,omitempty"`
|
|
Status string `json:"status,omitempty"` // idle, running, completed, failed
|
|
}
|