This directory contains an elite-level Longhorn distributed block storage configuration with advanced features for high availability, performance optimization, automated backups, and comprehensive monitoring.
- Distributed Block Storage: Replicated across multiple nodes for HA
- Dynamic Provisioning: Automatic PV provisioning via CSI
- Volume Expansion: Online volume expansion without downtime
- Snapshot Support: CSI snapshots and volume clones
- Data Locality: Optional data locality for database workloads
- Multiple Replicas: 1-3 replicas per storage class
- Fast Replica Rebuild: Accelerated rebuild after node failures
- Auto-Balance: Automatic replica distribution across nodes
- Zone/Disk Anti-Affinity: Replicas distributed across zones and disks
- Auto-Salvage: Automatic recovery from failures
- Automated Snapshots: Hourly, daily, weekly, monthly schedules
- Local Backups: Store backups locally or on NFS
- S3 Backups: Optional S3-compatible backup targets (MinIO, AWS S3)
- Snapshot Retention: Configurable retention policies
- Volume Cloning: Clone volumes for dev/test
- Cross-Cluster DR: Backup and restore across clusters
- SSD/NVMe Support: Disk selectors for high-performance storage
- Data Locality: Reduce network latency for databases
- Fast Rebuild: Quick replica reconstruction
- Concurrent Limits: Tuned for maximum throughput
- Filesystem Trim: Automatic space reclamation
- Prometheus Metrics: Full metrics export with ServiceMonitor
- Grafana Dashboard: Pre-built dashboard for IOPS, latency, capacity
- Built-in UI: Web-based management interface
- Volume Health Monitoring: Real-time health status
- Capacity Planning: Storage usage and trends
manifests/
├── longhorn-values.yaml # Helm values for elite configuration
├── longhorn.yaml # Generated Longhorn manifests (5408 lines)
├── longhorn-storage-classes.yaml # 7 storage class profiles
├── longhorn-recurring-jobs.yaml # Automated snapshot/backup jobs
├── longhorn-grafana-dashboard.yaml # Grafana dashboard ConfigMap
└── LONGHORN-ELITE-README.md # This file
- Replicas: 1
- Data Locality: Enabled
- Disk: SSD/NVMe only
- Best For: Databases (PostgreSQL, MySQL), Redis, high-IOPS apps
- Snapshots: Hourly
- Replicas: 3
- Data Locality: Disabled
- Anti-Affinity: Zone + Disk
- Reclaim Policy: Retain
- Best For: Critical production workloads, stateful services
- Snapshots: Daily + Weekly backups
- Replicas: 2
- Anti-Affinity: Soft
- Best For: General applications, web servers
- Snapshots: Daily
- Replicas: 1
- Data Locality: Enabled
- Best For: Dev/test, ephemeral data, CI/CD
- Snapshots: None
- Replicas: 3
- Data Locality: Enabled
- Disk: SSD/NVMe only
- Node Selector:
workload=database - Volume Binding: WaitForFirstConsumer
- Reclaim Policy: Retain
- Best For: PostgreSQL, MySQL, MongoDB, Cassandra
- Snapshots: Hourly + Daily backups
- Replicas: 2
- Fast Rebuild: Enabled
- Best For: Stateful apps, message queues
- Snapshots: Daily
- Replicas: 2
- Best For: Development, testing, versioning
- Snapshots: Hourly + Daily
- Talos Kubernetes Cluster: Running and healthy
- Storage: Each node should have:
- Disk space for Longhorn (recommend 100GB+ per node)
- Path
/var/lib/longhornavailable
- iSCSI Support: Already included in Talos
- Helm: Installed on your machine
kubectl apply -f manifests/longhorn.yamlWait for Longhorn to be ready:
kubectl -n longhorn-system rollout status deployment/longhorn-driver-deployer
kubectl -n longhorn-system rollout status deployment/longhorn-uikubectl apply -f manifests/longhorn-storage-classes.yamlVerify storage classes:
kubectl get storageclasskubectl apply -f manifests/longhorn-recurring-jobs.yamlVerify recurring jobs:
kubectl get recurringjobs -n longhorn-systemkubectl apply -f manifests/longhorn-grafana-dashboard.yamlPort-forward the UI:
kubectl port-forward -n longhorn-system svc/longhorn-frontend 8080:80Or configure ingress (update hostname in longhorn-values.yaml):
ingress:
enabled: true
host: longhorn.yourdomain.comOpen: http://localhost:8080 or https://longhorn.yourdomain.com
- Set up NFS server or use existing one
- Update Longhorn settings:
kubectl -n longhorn-system edit settings.longhorn.io backup-targetSet value to:
nfs://nfs-server.example.com:/longhorn-backups
- Create S3 credentials secret:
kubectl create secret generic s3-backup-secret \
-n longhorn-system \
--from-literal=AWS_ACCESS_KEY_ID=your-access-key \
--from-literal=AWS_SECRET_ACCESS_KEY=your-secret-key \
--from-literal=AWS_ENDPOINTS=https://s3.amazonaws.com \
--from-literal=AWS_REGION=us-east-1- Update backup target:
kubectl -n longhorn-system edit settings.longhorn.io backup-targetSet value to:
s3://bucket-name@region/path
- Set backup target credential secret:
kubectl -n longhorn-system edit settings.longhorn.io backup-target-credential-secretSet value to: s3-backup-secret
If using longhorn-database storage class:
kubectl label node <node-name> workload=databaseFor SSD/NVMe disks:
# In Longhorn UI, go to Node → Edit Node and Disks
# Add tags: ssd, nvme to appropriate disksOr via CLI (requires Longhorn API access).
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: my-app-data
namespace: production
spec:
accessModes:
- ReadWriteOnce
storageClassName: longhorn-high-availability
resources:
requests:
storage: 50GiapiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: postgres-data
namespace: databases
spec:
accessModes:
- ReadWriteOnce
storageClassName: longhorn-database
resources:
requests:
storage: 100GiapiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshot
metadata:
name: my-snapshot
namespace: production
spec:
volumeSnapshotClassName: longhorn-snapshot-class
source:
persistentVolumeClaimName: my-app-dataapiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: restored-data
namespace: production
spec:
accessModes:
- ReadWriteOnce
storageClassName: longhorn-high-availability
dataSource:
name: my-snapshot
kind: VolumeSnapshot
apiGroup: snapshot.storage.k8s.io
resources:
requests:
storage: 50GiapiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: cloned-volume
namespace: development
spec:
accessModes:
- ReadWriteOnce
storageClassName: longhorn-cost-optimized
dataSource:
name: my-app-data
kind: PersistentVolumeClaim
resources:
requests:
storage: 50GiServiceMonitor is automatically created at:
longhorn-system/longhorn-prometheus-servicemonitor
Key metrics:
longhorn_volume_actual_size_bytes- Volume sizelonghorn_volume_read_iops- Read IOPSlonghorn_volume_write_iops- Write IOPSlonghorn_volume_read_throughput- Read throughputlonghorn_volume_write_throughput- Write throughputlonghorn_volume_read_latency- Read latencylonghorn_volume_write_latency- Write latencylonghorn_node_storage_usage_bytes- Node storage usagelonghorn_volume_robustness- Volume health
Import the dashboard from longhorn-grafana-dashboard.yaml or access:
- Volume metrics (size, IOPS, throughput, latency)
- Node storage usage
- Volume health status
- Capacity planning
Access comprehensive monitoring:
kubectl port-forward -n longhorn-system svc/longhorn-frontend 8080:80Features:
- Volume management
- Snapshot management
- Backup management
- Node and disk management
- Event logs
- System settings
Backups run automatically via RecurringJobs:
- Daily: 1 AM, retain 7 backups
- Weekly: Sunday 4 AM, retain 4 backups
- Monthly: 1st of month 5 AM, retain 12 backups
Via Longhorn UI:
- Go to Volume
- Click "Create Backup"
- Backup is stored in configured backup target
Via CLI:
kubectl -n longhorn-system create -f - <<EOF
apiVersion: longhorn.io/v1beta2
kind: Backup
metadata:
name: manual-backup
spec:
snapshotName: <snapshot-name>
labels:
backup-type: manual
EOFVia Longhorn UI:
- Go to Backup
- Select backup
- Click "Restore"
- Create new PVC or restore to existing
- Source Cluster: Configure backup target (S3/NFS)
- Destination Cluster: Configure same backup target
- Restore: Backups will appear in destination cluster
- Create Volume: Restore from backup in destination cluster
| Job | Schedule | Type | Retention | Purpose |
|---|---|---|---|---|
| snapshot-hourly | Every hour | Snapshot | 24 | High-frequency snapshots |
| snapshot-daily | 2 AM daily | Snapshot | 7 | Daily snapshots |
| snapshot-weekly | Sunday 3 AM | Snapshot | 4 | Weekly snapshots |
| backup-daily | 1 AM daily | Backup | 7 | Daily backups |
| backup-weekly | Sunday 4 AM | Backup | 4 | Weekly backups |
| backup-monthly | 1st 5 AM | Backup | 12 | Monthly backups |
| snapshot-cleanup | 6 AM daily | Cleanup | N/A | Remove old snapshots |
| filesystem-trim | Saturday 2 AM | Trim | N/A | Reclaim space |
kubectl get volumes -n longhorn-systemkubectl get nodes.longhorn.io -n longhorn-systemAutomatic via snapshot-cleanup recurring job, or manual:
# In Longhorn UI: Volume → Snapshots → Delete- Backup all volumes
- Update
longhorn-values.yamlwith new version - Regenerate manifests:
helm template longhorn longhorn/longhorn \ --namespace longhorn-system \ --version <new-version> \ --values manifests/longhorn-values.yaml \ > manifests/longhorn.yaml
- Apply:
kubectl apply -f manifests/longhorn.yaml
Check:
- Node has available disk space
- iSCSI is working on node
- Instance manager pods are running
kubectl get pods -n longhorn-system | grep instance-manager
kubectl logs -n longhorn-system <instance-manager-pod>- Check disk I/O on nodes
- Verify replica count (more replicas = more overhead)
- Use
longhorn-high-performancestorage class - Enable data locality
- Use SSD/NVMe disks
- Verify backup target is accessible
- Check credentials (for S3)
- Check logs:
kubectl logs -n longhorn-system -l app=longhorn-manager
- Delete old snapshots
- Delete unused volumes
- Increase disk size on nodes
- Add more nodes
Use longhorn-database storage class with:
- 3 replicas for HA
- Data locality enabled
- SSD/NVMe disks
- Dedicated nodes with
workload=databaselabel
Use longhorn-high-performance with:
- 1 replica
- Data locality enabled
- NVMe disks
- Fast rebuild disabled (less overhead)
Use longhorn-cost-optimized with:
- 1 replica
- No automatic snapshots
- Manual snapshots as needed
- Encryption at Rest: Use encrypted disks/volumes at infrastructure level
- Backup Encryption: S3 backups can use server-side encryption
- RBAC: Longhorn respects Kubernetes RBAC
- Network Policies: Can apply network policies to longhorn-system namespace
- Secrets: Backup credentials stored in Kubernetes secrets
Longhorn works with Velero for full cluster backups:
velero install \
--use-volume-snapshots \
--snapshot-location-config region=defaultVelero will use Longhorn CSI snapshots automatically.
All manifests are GitOps-ready:
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: longhorn
spec:
source:
path: manifests
targetRevision: main
destination:
namespace: longhorn-systemServiceMonitor already configured. Ensure Prometheus Operator is running:
kubectl get servicemonitors -n longhorn-system# List volumes
kubectl get volumes -n longhorn-system
# List recurring jobs
kubectl get recurringjobs -n longhorn-system
# Check storage classes
kubectl get sc
# Port-forward UI
kubectl port-forward -n longhorn-system svc/longhorn-frontend 8080:80
# View manager logs
kubectl logs -n longhorn-system -l app=longhorn-manager
# Check node status
kubectl get nodes.longhorn.io -n longhorn-system
# List backups
kubectl get backups -n longhorn-systemNote: This is an elite configuration optimized for production use. Test thoroughly in development before deploying to production.