Migrate an application from EC2 to EKS with zero downtime. Walk me through it.

AdvancedScenarioMigrations
Answer

Situation read → Run old and new side by side, shift traffic gradually with a fast rollback path, and only then retire EC2.

What I'd do →

  1. Containerise: Dockerfile, externalise config and secrets (SSM or Secrets Manager via External Secrets), make the app stateless, and send logs to stdout.
  2. Build the EKS platform with Terraform: cluster, node groups or Karpenter, AWS Load Balancer Controller, IRSA or Pod Identity roles matching the old instance profile permissions.
  3. Deploy to EKS against the same database and dependencies, and test via a separate hostname.
  4. Shift traffic with weighted routing: Route 53 weighted records or ALB weighted target groups, 5% → 25% → 50% → 100%.
aws route53 change-resource-record-sets --hosted-zone-id Z123 --change-batch file://weights-25.json
  1. Compare error rates and latency between the two at each step; roll back by setting the weight to 0.
  2. Keep EC2 warm for a week after 100%, then decommission.

Why → Weighted routing gives gradual exposure and instant rollback without a big-bang cutover.

Interview tip → Mention security groups and IAM: pods need the same network access to RDS and the same permissions as the old instances.

All Real-World Interview questions Roadmap: Interview readiness

More on Migrations