A Kubernetes Job runs a task to completion. It creates one or more pods and ensures they finish successfully. Once done, the Job stops.
Click to reveal answer
beginner
What is a CronJob in Kubernetes?
A CronJob runs Jobs on a schedule, like a clock. It creates Jobs repeatedly at specified times, similar to a calendar alarm.
Click to reveal answer
intermediate
How does a Job ensure a task completes successfully?
A Job creates pods and watches them. If a pod fails, the Job starts a new pod until the task finishes successfully.
Click to reveal answer
beginner
What is the key field to set the schedule in a CronJob YAML?
The key field is spec.schedule. It uses cron format like "*/5 * * * *" to run every 5 minutes.
Click to reveal answer
intermediate
What happens if a CronJob's previous Job is still running when the next schedule starts?
By default, Kubernetes may skip starting a new Job if the previous one is still running, to avoid overlap. This behavior can be controlled with concurrencyPolicy.
Click to reveal answer
What does a Kubernetes Job do?
AManages network traffic
BRuns continuously without stopping
CSchedules tasks repeatedly on a timer
DRuns a task to completion and stops
✗ Incorrect
A Job runs a task and ensures it finishes successfully, then stops.
Which field defines the schedule for a CronJob?
Aspec.schedule
Bmetadata.name
Cspec.template
Dspec.replicas
✗ Incorrect
The schedule is set in spec.schedule using cron syntax.
What happens if a Job pod fails before completion?
AThe pod restarts automatically without Job intervention
BThe Job stops immediately
CThe Job creates a new pod to retry
DThe Job deletes itself
✗ Incorrect
The Job controller creates new pods to retry until success.
What is the default behavior if a CronJob's previous Job is still running at the next schedule?
ASkip starting a new Job
BStart a new Job anyway
CDelete the old Job
DSend an alert
✗ Incorrect
By default, Kubernetes skips starting a new Job to avoid overlap.
Which Kubernetes resource would you use to run a task every day at midnight?
AJob
BCronJob
CDeployment
DService
✗ Incorrect
CronJob runs Jobs on a schedule, such as daily at midnight.
Explain the difference between a Kubernetes Job and a CronJob.
Think about one-time tasks versus scheduled repeated tasks.
You got /3 concepts.
Describe how Kubernetes handles a Job pod failure during batch processing.
Focus on Job's retry mechanism.
You got /3 concepts.
Practice
(1/5)
1. What is the main difference between a Kubernetes Job and a CronJob?
easy
A. Job runs tasks repeatedly; CronJob runs a task once.
B. Job automatically restarts pods; CronJob does not.
C. Job is for long-running services; CronJob is for batch tasks.
D. Job runs a task once; CronJob runs tasks repeatedly on a schedule.
Solution
Step 1: Understand the purpose of a Job
A Kubernetes Job runs a batch task once and completes when the task finishes.
Step 2: Understand the purpose of a CronJob
A CronJob schedules Jobs to run repeatedly at specified times, like a clock.
Final Answer:
Job runs a task once; CronJob runs tasks repeatedly on a schedule. -> Option D
Quick Check:
Job = one-time, CronJob = scheduled repeat [OK]
Hint: Jobs run once; CronJobs run on a schedule [OK]
Common Mistakes:
Confusing Job as repeating task
Thinking CronJob runs only once
Mixing up Job with long-running services
2. Which of the following is the correct minimal YAML snippet to define a Kubernetes Job?
Hint: CronJob schedule "*/5 * * * *" means every 5 minutes [OK]
Common Mistakes:
Thinking CronJob runs only once
Assuming continuous running container
Ignoring the command output
4. You created a CronJob but notice it never runs. Which YAML mistake could cause this?
medium
A. Missing schedule field in the CronJob spec.
B. Using restartPolicy: Always in the Job template.
C. Setting image to a valid container image.
D. Defining command as an array.
Solution
Step 1: Check required CronJob fields
The schedule field is mandatory to tell when to run the job.
Step 2: Identify impact of missing schedule
Without schedule, the CronJob controller cannot trigger jobs, so none run.
Final Answer:
Missing schedule field prevents CronJob from running. -> Option A
Quick Check:
CronJob needs schedule to run [OK]
Hint: CronJob must have schedule field to run [OK]
Common Mistakes:
Using restartPolicy Always (allowed but not cause no run)
Thinking image or command cause no run
Ignoring missing schedule field
5. You want to run a cleanup task every day at midnight using a CronJob. Which schedule string correctly sets this time?
hard
A. "0 * * * 0"
B. "0 0 * * *"
C. "* * 0 * *"
D. "0 12 * * *"
Solution
Step 1: Understand cron schedule format
The format is: minute hour day month weekday.
Step 2: Interpret each option
"0 0 * * *": "0 0 * * *" means at minute 0, hour 0 (midnight) every day. "* * 0 * *": "* * 0 * *" is invalid because day 0 does not exist. "0 * * * 0": "0 * * * 0" means every hour at minute 0 on Sundays only. "0 12 * * *": "0 12 * * *" means noon every day.
Final Answer:
"0 0 * * *" runs daily at midnight. -> Option B
Quick Check:
Midnight daily = "0 0 * * *" [OK]
Hint: Midnight daily cron is "0 0 * * *" [OK]
Common Mistakes:
Using day 0 which is invalid
Confusing hour 12 (noon) with midnight
Misplacing fields in schedule string
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.