home-lab/documentation/DEPLOY_RS_INTEGRATION.md
2025-06-15 11:01:41 +02:00

161 lines
4.8 KiB
Markdown

# Deploy-rs Integration Summary
## Overview
Successfully integrated deploy-rs into the Home Lab infrastructure as a modern, production-ready deployment method alongside the existing shell script approach.
## Completed Tasks ✅
### Task 1: Add deploy-rs input to flake.nix ✅
- Added `deploy-rs.url = "github:serokell/deploy-rs"` to flake inputs
- Exposed deploy-rs in outputs function parameters
- Validated with `nix flake check`
### Task 2: Create basic deploy-rs configuration ✅
- Configured all 4 machines in `deploy.nodes` section
- Used Tailscale hostnames for reliable connectivity
- Set up proper SSH users and activation paths
### Task 3: Add deploy-rs health checks ✅
- Configured activation timeouts: 180s (local), 240s (VPS)
- Set confirm timeouts: 30s for all machines
- Enabled autoRollback and magicRollback for safety
### Task 4: Test deploy-rs on sleeper-service ✅
**Status**: Successfully completed on June 15, 2025
**Results**:
- ✅ Dry-run deployment successful
- ✅ Actual deployment successful
- ✅ Service management (transmission.service restart)
- ✅ Automatic health checks passed
- ✅ Magic rollback protection enabled
- ✅ New NixOS generation created (192)
- ✅ Tailscale connectivity working perfectly
### Task 5: Integrate deploy-rs with lab tool ✅
**Status**: Successfully completed on June 15, 2025
**New Commands Added**:
- `lab deploy-rs <machine> [--dry-run]` - Modern deployment with automatic rollback
- `lab update-flake` - Update package versions and validate configuration
- `lab hybrid-update [target] [--dry-run]` - Combined flake update + deploy-rs deployment
**Features**:
- Hybrid approach combining package updates with deployment safety
- Maintains existing legacy deployment commands for compatibility
- Comprehensive help documentation with examples
- Error handling and validation
## Deployment Methods Comparison
| Feature | Legacy (SSH + rsync) | Deploy-rs | Hybrid Update |
|---------|---------------------|-----------|---------------|
| **Speed** | Moderate | Fast | Fast |
| **Safety** | Manual rollback | Automatic rollback | Automatic rollback |
| **Package Updates** | Manual | No | Automatic |
| **Health Checks** | None | Automatic | Automatic |
| **Parallel Deployment** | No | Yes | Yes |
| **Learning Curve** | Low | Medium | Medium |
## Usage Examples
### Basic Deploy-rs Usage
```bash
# Deploy with automatic rollback protection
lab deploy-rs sleeper-service
# Test deployment without applying
lab deploy-rs sleeper-service --dry-run
```
### Hybrid Update Usage (Recommended)
```bash
# Update packages and deploy to specific machine
lab hybrid-update sleeper-service
# Update all machines with latest packages
lab hybrid-update all --dry-run # Test first
lab hybrid-update all # Apply updates
# Just update flake inputs
lab update-flake
```
### Legacy Usage (Still Available)
```bash
# Traditional deployment method
lab deploy sleeper-service boot
lab update boot
```
## Technical Implementation
### Deploy-rs Configuration
```nix
deploy.nodes = {
sleeper-service = {
hostname = "sleeper-service.tail807ea.ts.net";
profiles.system = {
user = "root";
path = deploy-rs.lib.x86_64-linux.activate.nixos
self.nixosConfigurations.sleeper-service;
sshUser = "sma";
sudo = "sudo -u";
autoRollback = true;
magicRollback = true;
activationTimeout = 180;
confirmTimeout = 30;
};
};
# ... other machines
};
```
### Lab Tool Integration
The lab tool now provides three deployment approaches:
1. **Legacy**: Reliable SSH + rsync method (existing workflow)
2. **Modern**: Direct deploy-rs usage with safety features
3. **Hybrid**: Automated package updates + deploy-rs deployment
## Next Steps
### Pending Tasks
- **Task 6**: Test deploy-rs on all machines (grey-area, reverse-proxy, congenital-optimist)
- **Task 7**: Add deploy-rs status monitoring to lab tool
- **Task 8**: Create deployment workflow documentation
- **Task 9**: Optimize deploy-rs for home lab network
- **Task 10**: Implement emergency rollback procedures
### Recommendations
1. Use **hybrid-update** for regular maintenance (combines updates + safety)
2. Use **deploy-rs** for quick configuration changes
3. Keep **legacy deploy** as fallback method
4. Test **parallel deployment** to multiple machines
## Benefits Achieved
-**Automatic Rollback**: Failed deployments revert automatically
-**Health Checks**: Validates deployment success before committing
-**Package Updates**: Streamlined update process with safety
-**Parallel Deployment**: Can deploy to multiple machines simultaneously
-**Generation Management**: Proper NixOS generation tracking
-**Network Resilience**: Robust SSH connection handling
The deploy-rs integration successfully modernizes the Home Lab deployment infrastructure while maintaining compatibility with existing workflows.