Member-only story

CronJob In Kubernetes

Maciej
3 min readApr 16, 2021

--

Introduction

CronJob in Kubernetes is good for handling Deployment like Cron, but it is difficult to understand because there are many API fields. So I would like to organized it, next, show how it works.

CronJobSpec API fields

All information about API fields we can find in link below:

https://v1-17.docs.kubernetes.io/docs/reference/generated/kubernetes-api/v1.17/#cronjob-v1beta1-batch

The concurrencyPolicy is a little difficult to understand, so I added it.

Example:

If a job takes 2 minutes to execute, but cron is set to be executed every minute, jobs will occur at the same time.

⚠️ Allow is an option that allows it, Forbid prohibits it, and Replace gives priority to new jobs.

The StartingDeadlineSeconds is also difficult to understand, so supplement it.

Example:

Suppose a job is delayed or executed for some reason. At that time, you can roughly set how many seconds will you wait. If this is 0, it won’t happen again, and if it’s 30, it will wait for 30 seconds. If execution is not started within the allowable time, it is considered as a failed job.

API field for CronJobStatus

--

--

Maciej
Maciej

Written by Maciej

DevOps Consultant. I’m strongly focused on automation, security, and reliability.

No responses yet