You're migrating a cron job from an EC2 crontab to Kubernetes. What can go wrong?
BeginnerScenarioMigrations
Answer
Situation read → Crontab on one VM guarantees one runner and local disk. Kubernetes CronJobs don't give you either by default.
What I'd do →
- Set
concurrencyPolicy: Forbidso a slow run doesn't overlap with the next. - Set
startingDeadlineSecondsand accept that missed schedules (controller down) may not run. - Make the job idempotent: Kubernetes may run it more than once in rare cases.
- Timezone: set
timeZone: "Asia/Kolkata"in the spec instead of relying on node time. - Replace local file paths with S3 or a PVC, and the old mail-on-output with logs plus an alert on failed jobs.
spec:
schedule: "30 2 * * *"
timeZone: "Asia/Kolkata"
concurrencyPolicy: Forbid
successfulJobsHistoryLimit: 3
failedJobsHistoryLimit: 3
Why → Overlapping or double runs of a billing job are a real incident.
Interview tip → Mention idempotency; CronJobs are at-least-once in edge cases.
More on Migrations
Migrate an application from EC2 to EKS with zero downtime. Walk me through it.AdvancedMigrate a database from on-prem MySQL to Amazon RDS with minimal downtime. How?AdvancedYou need to move Terraform state from local files to an S3 backend. How?BeginnerMigrate CI from Jenkins to GitHub Actions for 80 repositories. How do you plan it?IntermediateUpgrade an EKS cluster from 1.30 to 1.31 in production. What's your process?IntermediateMove from a monolith to microservices. What's the DevOps side of the migration?Advanced