Files
seaweedfs/weed/admin/DESIGN.md
T
Chris LuandCopilot 1defee3d68 Add admin component (#6928)
* init version

* relocate

* add s3 bucket link

* refactor handlers into weed/admin folder

* fix login logout

* adding favicon

* remove fall back to http get topology

* grpc dial option, disk total capacity

* show filer count

* fix each volume disk usage

* add filers to dashboard

* adding hosts, volumes, collections

* refactor code and menu

* remove "refresh" button

* fix data for collections

* rename cluster hosts into volume servers

* add masters, filers

* reorder

* adding file browser

* create folder and upload files

* add filer version, created at time

* remove mock data

* remove fields

* fix submenu item highlighting

* fix bucket creation

* purge files

* delete multiple

* fix bucket creation

* remove region from buckets

* add object store with buckets and users

* rendering permission

* refactor

* get bucket objects and size

* link to file browser

* add file size and count for collections page

* paginate the volumes

* fix possible SSRF

https://github.com/seaweedfs/seaweedfs/pull/6928/checks?check_run_id=45108469801

* Update weed/command/admin.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update weed/command/admin.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* fix build

* import

* remove filer CLI option

* remove filer option

* remove CLI options

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-07-01 01:28:09 -07:00

321 lines
12 KiB
Markdown

# SeaweedFS Admin Interface Web Component Design
## Overview
The SeaweedFS Admin Interface is a modern web-based administration interface for SeaweedFS clusters, following the **Gin + Templ + HTMX** architecture pattern. It provides comprehensive cluster management, monitoring, and maintenance capabilities through an intuitive web interface.
## Architecture
### Technology Stack
- **Backend Framework**: Gin (Go HTTP web framework)
- **Template Engine**: Templ (Type-safe Go templates)
- **Frontend Enhancement**: HTMX (Dynamic interactions without JavaScript frameworks)
- **CSS Framework**: Bootstrap 5 (Modern responsive design)
- **Icons**: Font Awesome 6 (Comprehensive icon library)
- **Authentication**: Session-based with configurable credentials
### Directory Structure
```
weed/admin/
├── admin.go # Main entry point & router setup
├── dash/ # Core admin logic
│ ├── admin_server.go # Server struct & cluster operations
│ ├── handler_auth.go # Authentication handlers
│ ├── handler_admin.go # Main admin handlers
│ ├── middleware.go # Authentication middleware
│ └── ... # Additional handlers
├── view/ # Template components
│ ├── layout/
│ │ └── layout.templ # Base layout & login form
│ └── app/
│ ├── admin.templ # Admin page template
│ └── template_helpers.go # Formatting utilities
├── static/ # Static assets
│ ├── css/
│ │ └── admin.css # Custom styles
│ └── js/
│ └── admin.js # Interactive functionality
└── templates/ # Embedded templates
```
## Core Features
### 1. **Cluster Management**
#### Topology Visualization
- **Data Center/Rack/Node Hierarchy**: Visual representation of cluster topology
- **Real-time Status Monitoring**: Live status updates for all cluster components
- **Capacity Planning**: Volume utilization and capacity tracking
- **Health Assessment**: Automated health scoring and alerts
#### Master Node Management
- **Leader/Follower Status**: Clear indication of Raft leadership
- **Master Configuration**: View and modify master settings
- **Cluster Membership**: Add/remove master nodes
- **Heartbeat Monitoring**: Track master node availability
#### Volume Server Operations
- **Server Registration**: Automatic detection of new volume servers
- **Disk Usage Monitoring**: Real-time disk space and volume tracking
- **Performance Metrics**: I/O statistics and throughput monitoring
- **Maintenance Mode**: Graceful server shutdown and maintenance
### 2. **Volume Management**
#### Volume Operations
- **Volume Creation**: Create new volumes with replication settings
- **Volume Listing**: Comprehensive volume inventory with search/filter
- **Volume Details**: Detailed information per volume (files, size, replicas)
- **Volume Migration**: Move volumes between servers
- **Volume Deletion**: Safe volume removal with confirmation
#### Storage Operations
- **Volume Growing**: Automatic volume expansion based on policies
- **Vacuum Operations**: Reclaim deleted file space
- **Compaction**: Optimize volume storage efficiency
- **Rebalancing**: Distribute volumes evenly across servers
### 3. **File Management**
#### File Browser
- **Directory Navigation**: Browse filer directories with breadcrumbs
- **File Operations**: Upload, download, delete, rename files
- **Batch Operations**: Multi-file operations with progress tracking
- **Metadata Display**: File attributes, timestamps, permissions
- **Search Functionality**: Find files by name, type, or content
#### Storage Analytics
- **Usage Statistics**: File count, size distribution, growth trends
- **Access Patterns**: Popular files and access frequency
- **Storage Efficiency**: Compression ratios and duplicate detection
### 4. **Monitoring & Metrics**
#### Real-time Dashboards
- **System Overview**: Cluster health at a glance
- **Performance Metrics**: Throughput, latency, and error rates
- **Resource Utilization**: CPU, memory, disk, and network usage
- **Historical Trends**: Long-term performance analysis
#### Alerting System
- **Threshold Monitoring**: Configurable alerts for key metrics
- **Health Checks**: Automated health assessment and scoring
- **Notification Channels**: Email, webhook, and dashboard notifications
### 5. **Configuration Management**
#### Cluster Configuration
- **Master Settings**: Replication, security, and operational parameters
- **Volume Server Config**: Storage paths, limits, and performance settings
- **Filer Configuration**: Metadata storage and caching options
- **Security Settings**: Authentication, authorization, and encryption
#### Backup & Restore
- **Configuration Backup**: Export cluster configuration
- **Configuration Restore**: Import and apply saved configurations
- **Version Control**: Track configuration changes over time
### 6. **System Maintenance**
#### Maintenance Operations
- **Garbage Collection**: Clean up orphaned files and metadata
- **Volume Repair**: Fix corrupted or inconsistent volumes
- **Cluster Validation**: Verify cluster integrity and consistency
- **Performance Tuning**: Optimize cluster performance parameters
#### Log Management
- **Log Aggregation**: Centralized logging from all cluster components
- **Log Analysis**: Search, filter, and analyze system logs
- **Error Tracking**: Identify and track system errors and warnings
- **Log Export**: Download logs for external analysis
## User Interface Design
### Layout Components
#### Header Navigation
- **Cluster Status Indicator**: Quick health overview
- **User Information**: Current user and session details
- **Quick Actions**: Frequently used operations
- **Search Bar**: Global search across cluster resources
#### Sidebar Navigation
- **Cluster Section**: Topology, status, and management
- **Management Section**: Files, volumes, and operations
- **System Section**: Configuration, logs, and maintenance
- **Contextual Actions**: Dynamic actions based on current view
#### Main Content Area
- **Dashboard Cards**: Key metrics and status summaries
- **Data Tables**: Sortable, filterable resource listings
- **Interactive Charts**: Real-time metrics visualization
- **Action Panels**: Operation forms and bulk actions
### Responsive Design
- **Mobile Responsive**: Optimized for tablets and mobile devices
- **Progressive Enhancement**: Works with JavaScript disabled
- **Accessibility**: WCAG 2.1 compliant interface
- **Theme Support**: Light/dark mode support
## Security Features
### Authentication & Authorization
- **Configurable Authentication**: Optional password protection
- **Session Management**: Secure session handling with timeouts
- **Role-based Access**: Different permission levels for users
- **Audit Logging**: Track all administrative actions
### Security Hardening
- **HTTPS Support**: TLS encryption for all communications
- **CSRF Protection**: Cross-site request forgery prevention
- **Input Validation**: Comprehensive input sanitization
- **Rate Limiting**: Prevent abuse and DoS attacks
## API Design
### RESTful Endpoints
```go
// Public endpoints
GET /health # Health check
GET /login # Login form
POST /login # Process login
GET /logout # Logout
// Protected endpoints
GET /admin # Main admin interface
GET /overview # Cluster overview API
// Cluster management
GET /cluster # Cluster topology view
GET /cluster/topology # Topology data API
GET /cluster/status # Cluster status API
POST /cluster/grow # Grow volumes
POST /cluster/vacuum # Vacuum operation
POST /cluster/rebalance # Rebalance cluster
// Volume management
GET /volumes # Volumes list page
GET /volumes/list # Volumes data API
GET /volumes/details/:id # Volume details
POST /volumes/create # Create volume
DELETE /volumes/delete/:id # Delete volume
// File management
GET /filer # File browser page
GET /filer/browser # File browser interface
GET /filer/browser/api/* # File operations API
POST /filer/upload # File upload
DELETE /filer/delete # File deletion
// Monitoring
GET /metrics # Metrics dashboard
GET /metrics/data # Metrics data API
GET /metrics/realtime # Real-time metrics
GET /logs # Logs viewer
GET /logs/download/:type # Download logs
// Configuration
GET /config # Configuration page
GET /config/current # Current configuration
POST /config/update # Update configuration
GET /config/backup # Backup configuration
// Maintenance
GET /maintenance # Maintenance page
POST /maintenance/gc # Garbage collection
POST /maintenance/compact # Volume compaction
GET /maintenance/status # Maintenance status
```
## Development Guidelines
### Code Organization
- **Handler Separation**: Separate files for different functional areas
- **Type Safety**: Use strongly typed structures for all data
- **Error Handling**: Comprehensive error handling and user feedback
- **Testing**: Unit and integration tests for all components
### Performance Considerations
- **Caching Strategy**: Intelligent caching of cluster topology and metrics
- **Lazy Loading**: Load data on demand to improve responsiveness
- **Batch Operations**: Efficient bulk operations for large datasets
- **Compression**: Gzip compression for API responses
### Monitoring Integration
- **Metrics Export**: Prometheus-compatible metrics endpoint
- **Health Checks**: Kubernetes-style health and readiness probes
- **Distributed Tracing**: OpenTelemetry integration for request tracing
- **Structured Logging**: JSON logging for better observability
## Deployment Options
### Standalone Deployment
```bash
# Start dashboard server
./weed dashboard -port=9999 \
-masters="master1:9333,master2:9333" \
-filer="filer:8888" \
-adminUser="admin" \
-adminPassword="secretpassword"
```
### Docker Deployment
```yaml
# docker-compose.yml
version: '3.8'
services:
dashboard:
image: seaweedfs:latest
command: dashboard -port=9999 -masters=master:9333 -filer=filer:8888
ports:
- "9999:9999"
environment:
- ADMIN_USER=admin
- ADMIN_PASSWORD=secretpassword
```
### Kubernetes Deployment
```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: seaweedfs-dashboard
spec:
replicas: 1
selector:
matchLabels:
app: seaweedfs-dashboard
template:
metadata:
labels:
app: seaweedfs-dashboard
spec:
containers:
- name: dashboard
image: seaweedfs:latest
command: ["weed", "dashboard"]
args:
- "-port=9999"
- "-masters=seaweedfs-master:9333"
- "-filer=seaweedfs-filer:8888"
ports:
- containerPort: 9999
```
## Future Enhancements
### Advanced Features
- **Multi-cluster Management**: Manage multiple SeaweedFS clusters
- **Advanced Analytics**: Machine learning-powered insights
- **Custom Dashboards**: User-configurable dashboard layouts
- **API Integration**: Webhook integration with external systems
### Enterprise Features
- **SSO Integration**: LDAP, OAuth, and SAML authentication
- **Advanced RBAC**: Fine-grained permission system
- **Audit Compliance**: SOX, HIPAA, and PCI compliance features
- **High Availability**: Multi-instance dashboard deployment
This design provides a comprehensive, modern, and scalable web interface for SeaweedFS administration, following industry best practices and providing an excellent user experience for cluster operators and administrators.