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 →

  1. Set concurrencyPolicy: Forbid so a slow run doesn't overlap with the next.
  2. Set startingDeadlineSeconds and accept that missed schedules (controller down) may not run.
  3. Make the job idempotent: Kubernetes may run it more than once in rare cases.
  4. Timezone: set timeZone: "Asia/Kolkata" in the spec instead of relying on node time.
  5. 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.

All Real-World Interview questions Roadmap: Interview readiness

More on Migrations