Documentation Index
Fetch the complete documentation index at: https://mintlify.com/traefik/traefik/llms.txt
Use this file to discover all available pages before exploring further.
Migration Best Practices
This guide provides general best practices and strategies for migrating Traefik Proxy between versions, ensuring minimal downtime and risk.General Migration Principles
Plan Thoroughly
Successful migrations start with comprehensive planning:Review Release Notes
Carefully read changelog and migration guides for all versions between your current and target version.
Test Before Production
Essential testing environments:- Development Environment: Initial testing and experimentation
- Staging Environment: Production-like testing with realistic workloads
- Canary/Preview Environment: Gradual production traffic testing
Pre-Migration Checklist
Before starting any migration:1. Backup Everything
Always create complete backups before making any changes.
- ✅ Static configuration files
- ✅ Dynamic configuration (if using file provider)
- ✅ ACME certificates and
acme.jsonfile - ✅ Custom TLS certificates
- ✅ Kubernetes manifests and CRDs
- ✅ Docker Compose files or Swarm stack definitions
- ✅ Environment variables and secrets
- ✅ Plugin configurations
2. Document Current State
Create comprehensive documentation of your current setup:- Current Traefik version
- Enabled providers and their configurations
- Number of routers, services, and middleware
- Custom features or plugins in use
- Integration points (monitoring, logging, tracing)
- Performance baselines (request rate, latency, error rate)
3. Establish Monitoring
Monitoring requirements: Metrics to Track:- Request rate (requests per second)
- Response time percentiles (p50, p90, p95, p99)
- Error rates by status code (4xx, 5xx)
- Active connections
- Backend health status
- Certificate expiration dates
- Resource usage (CPU, memory, network)
- Prometheus + Grafana for metrics
- ELK Stack or Loki for logs
- Jaeger or OTLP-compatible backend for tracing
- Alert manager for critical notifications
4. Test Configuration Compatibility
Validate configuration before deployment:Migration Strategies
Choose the right strategy based on your environment and risk tolerance:Strategy 1: Rolling Update
Best for: Kubernetes deployments, high-availability setups Advantages:- Minimal downtime
- Gradual rollout
- Easy rollback
Kubernetes Rolling Update
Kubernetes Rolling Update
Strategy 2: Blue-Green Deployment
Best for: Critical production environments, maximum safety Advantages:- Zero downtime
- Full testing in production environment
- Instant rollback capability
Kubernetes Blue-Green Example
Kubernetes Blue-Green Example
Strategy 3: Canary Deployment
Best for: Progressive validation with real traffic Advantages:- Early issue detection
- Minimal impact radius
- Data-driven decision making
Strategy 4: In-Place Upgrade
Best for: Single-instance deployments, development environments Steps:- Stop current Traefik instance
- Update configuration files
- Update Traefik binary or container image
- Start new version
- Verify functionality
Configuration Management
Version Control
Always use version control for Traefik configurations:- Tag each production release:
git tag v3.6.0-production - Document changes in commit messages
- Use branches for testing different configurations
- Never commit secrets (use
.gitignore)
Configuration Validation
Validate configurations before deployment:Static Configuration Validation
Static Configuration Validation
Dynamic Configuration Validation
Dynamic Configuration Validation
Environment-Specific Configurations
Maintain separate configurations for different environments:Testing Strategy
Test Levels
Testing Checklist
Routing Tests:- ✅ All defined routes are accessible
- ✅ Path matching works as expected
- ✅ Host-based routing functions correctly
- ✅ Priority-based routing resolves correctly
- ✅ Wildcard and regex patterns match appropriately
- ✅ Authentication middleware blocks unauthorized access
- ✅ Rate limiting activates under load
- ✅ Headers are added/removed correctly
- ✅ Redirects function as configured
- ✅ Compression activates for appropriate content types
- ✅ Circuit breakers trigger on backend failures
- ✅ HTTPS endpoints respond correctly
- ✅ Certificate validation works
- ✅ SNI routing functions properly
- ✅ TLS versions and cipher suites are correct
- ✅ ACME certificate generation/renewal works
- ✅ HTTP to HTTPS redirection functions
- ✅ Load balancing distributes traffic correctly
- ✅ Health checks detect backend failures
- ✅ Sticky sessions maintain session affinity
- ✅ Circuit breaker prevents cascading failures
- ✅ Retry logic handles transient failures
- ✅ Metrics are exported correctly
- ✅ Access logs contain expected fields
- ✅ Tracing spans are created and exported
- ✅ Health check endpoint responds
- ✅ Dashboard is accessible (if enabled)
Automated Testing
Implement automated tests for consistent validation:Shell Script Testing Example
Shell Script Testing Example
Rollback Procedures
Prepare rollback procedures before migration:Rollback Decision Criteria
Rollback immediately if:- ❌ Error rate increases by >5%
- ❌ Response time degrades by >20%
- ❌ Critical functionality breaks
- ❌ Backend health checks fail
- ❌ Certificate issues prevent HTTPS
- ❌ Configuration errors prevent startup
Kubernetes Rollback
Docker Swarm Rollback
Configuration Rollback
Observability During Migration
Logging Best Practices
Enable detailed logging during migration:Metrics Monitoring
Track key metrics before, during, and after migration: Pre-Migration Baseline:- Average request rate
- Response time percentiles
- Error rate by status code
- Resource utilization
- Compare metrics between old and new versions
- Watch for anomalies or degradation
- Track rollout progress
- Verify metrics return to baseline
- Monitor for 24-48 hours for delayed issues
- Document any performance improvements
Alerting Configuration
Set up alerts for critical issues:Prometheus Alert Rules Example
Prometheus Alert Rules Example
Common Migration Pitfalls
Pitfall 1: Insufficient Testing
Pitfall 2: Ignoring Breaking Changes
Pitfall 3: No Rollback Plan
Pitfall 4: Missing Backups
Pitfall 5: Inadequate Monitoring
Pitfall 6: Big Bang Migration
Pitfall 7: Skipping Version Compatibility
Post-Migration Tasks
After successful migration:Configuration Optimization
After migration, optimize your configuration:- Remove compatibility shims (e.g.,
core.defaultRuleSyntax: v2) - Adopt new features (passive health checks, TCP health checks, etc.)
- Simplify router rules using v3 syntax improvements
- Review and update deprecated middleware
- Optimize load balancing strategies
- Update TLS configurations for better security
Performance Tuning
Tune Traefik for optimal performance:Migration Checklist Template
Use this checklist for your migrations:Pre-Migration
- Review release notes and changelog
- Identify all breaking changes
- Create configuration backups
- Backup certificates and secrets
- Document current state and baselines
- Set up monitoring and alerting
- Prepare rollback procedures
- Update test environment
- Test new version in development
- Test new version in staging
- Create migration timeline
- Schedule migration window
- Notify stakeholders
During Migration
- Deploy to test environment first
- Verify all tests pass
- Deploy to staging environment
- Run load tests
- Begin production rollout
- Monitor metrics continuously
- Watch error logs
- Verify backend health
- Test critical user flows
- Validate SSL/TLS
- Check middleware behavior
Post-Migration
- Monitor for 24-48 hours
- Verify all metrics stable
- Check for deprecation warnings
- Update documentation
- Clean up old configurations
- Remove compatibility modes
- Optimize configuration
- Update disaster recovery docs
- Conduct team retrospective
- Document lessons learned
Additional Resources
- Traefik Documentation
- v2 to v3 Migration Guide
- Traefik Community Forum
- Traefik GitHub Issues
- Traefik Blog
Following these best practices will help ensure your Traefik migration is smooth, safe, and successful. Remember: thorough planning and testing are the keys to successful migrations.