

# Rollback and cleanup
<a name="rollback-and-cleanup"></a>

If issues arise after migration, use the rollback script to remove migrated resources from the target Amazon EKS cluster:

1. Switch kubectl context to the target Amazon EKS cluster:

```
aws eks update-kubeconfig --name <cluster-name> --region <region>
```

1. Run a dry-run rollback:

```
cd rollback/
python3 rollback_eks_migration.py --dry-run
```

1. Review the dry-run rollback output. Confirm that only the expected migrated resources are listed for deletion. The rollback proceeds in reverse order: networking → workloads → CRDs → config → storage → RBAC → namespaces.

1. Run the full rollback:

```
python3 rollback_eks_migration.py
```

1. Review the rollback report. The `rollback_report.json` file is saved alongside the migration report with details of what was deleted, what was skipped, and any errors encountered.

1. Verify cleanup by running these commands to confirm that all migrated resources have been removed from the targetAmazon EKS cluster:

```
kubectl get namespaces
kubectl get deployments --all-namespaces
kubectl get services --all-namespaces
```