Migration Procedures Reference
This document provides detailed procedures for migrating between different KubeZero configurations and versions.
Pre-Migration Checklist
Before starting any migration, ensure you have:
- Complete backup of your current cluster
- Migration plan with rollback procedures
- Maintenance window scheduled
- Access credentials verified
- Monitoring in place to track migration progress
Version Migration
Minor Version Updates
For minor version updates (e.g., 1.2.0 to 1.2.1):
# Update the KubeZero stack version
kubectl patch stack my-stack --type='merge' -p='{"spec":{"version":"1.2.1"}}'
# Monitor the rollout
kubectl get pods -n kubezero-system -w
Major Version Updates
For major version updates (e.g., 1.x to 2.x):
# Create backup before migration
kubectl apply -f backup-job.yaml
# Update stack configuration
kubectl apply -f new-stack-config.yaml
# Monitor migration progress
kubectl describe stack my-stack
Stack Migration
Migrating Between Stack Types
From EKS to GKE
- Prepare new GKE cluster:
# Deploy base GKE stack
kubectl apply -f gke-stack.yaml
- Migrate workloads:
# Export workloads from EKS
kubectl get all --all-namespaces -o yaml > workloads-backup.yaml
# Apply to GKE cluster
kubectl apply -f workloads-backup.yaml
- Update DNS and load balancers:
# Update external DNS records
kubectl patch service ingress-nginx-controller -p '{"spec":{"loadBalancerIP":"NEW_IP"}}'
Module Migration
Adding New Modules
# Add new module to existing stack
spec:
modules:
- name: monitoring
version: "1.0.0"
enabled: true
config:
prometheus:
retention: "30d"
grafana:
adminPassword: "secretPassword"
Removing Modules
# Disable module before removal
spec:
modules:
- name: old-module
enabled: false
Wait for resources to be cleaned up, then remove from configuration.
Data Migration
Persistent Volume Migration
Cloud Provider Migration
For migrating persistent volumes between cloud providers:
# Create volume snapshots
kubectl apply -f volume-snapshot.yaml
# Restore in new cluster
kubectl apply -f volume-restore.yaml
Storage Class Migration
# Update storage class for volumes
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
annotations:
volume.beta.kubernetes.io/storage-class: "new-storage-class"
Database Migration
PostgreSQL Migration
# Create database dump
kubectl exec postgres-pod -- pg_dump mydb > backup.sql
# Restore in new cluster
kubectl exec new-postgres-pod -- psql mydb < backup.sql
Configuration Migration
GitOps Repository Migration
- Create new repository structure:
# Clone existing repo
git clone https://github.com/old-org/kubezero-config.git
# Update repository structure
mv kubezero-config kubezero-config-new
cd kubezero-config-new
- Update ArgoCD configuration:
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: kubezero-app
spec:
source:
repoURL: https://github.com/new-org/kubezero-config.git
path: stacks/production
Secret Migration
External Secrets Migration
# Update secret store references
apiVersion: external-secrets.io/v1beta1
kind: SecretStore
metadata:
name: vault-backend
spec:
provider:
vault:
server: "https://new-vault.example.com"
path: "secret"
Post-Migration Validation
Health Checks
# Verify all pods are running
kubectl get pods --all-namespaces
# Check service endpoints
kubectl get endpoints
# Validate ingress connectivity
curl -I https://myapp.example.com
Performance Testing
# Run load tests
kubectl apply -f load-test-job.yaml
# Monitor resource usage
kubectl top nodes
kubectl top pods
Rollback Procedures
Emergency Rollback
If migration fails, execute immediate rollback:
# Restore from backup
kubectl apply -f cluster-restore.yaml
# Revert DNS changes
# Update load balancer targets
# Notify stakeholders
Gradual Rollback
For non-critical issues:
# Scale down new deployment
kubectl scale deployment new-app --replicas=0
# Scale up old deployment
kubectl scale deployment old-app --replicas=3
# Monitor traffic shift
Troubleshooting
Common Issues
- Resource conflicts: Check for overlapping resource names
- Network policies: Verify connectivity between migrated components
- Storage permissions: Ensure proper PVC access rights
- Service accounts: Update RBAC permissions as needed
Diagnostic Commands
# Check events for errors
kubectl get events --sort-by='.lastTimestamp'
# Examine pod logs
kubectl logs -f deployment/my-app
# Describe problematic resources
kubectl describe pod failing-pod