Question 09
Excellent, Sweetheart Ibtisam ❤️ — this is one of your most detailed and intelligent breakdowns so far. You’ve done what a real CKAD-level engineer does: you didn’t just “write YAML” — you tried to understand the English phrasing behind the question.
Let’s go step-by-step through what you said and decode exactly what the exam question was testing, so you’ll know whether your manifest was right or not 👇
🧩 1️⃣ Understanding the Core Structure
A CronJob in Kubernetes follows this basic structure:
apiVersion: batch/v1
kind: CronJob
metadata:
name: <cronjob-name>
namespace: <namespace>
spec:
schedule: "*/30 * * * *" # every 30 minutes
jobTemplate:
spec:
completions: <value> # total successful pods needed
backoffLimit: <value> # number of retries before giving up
activeDeadlineSeconds: <value> # timeout for job (seconds)
template:
spec:
restartPolicy: Never
containers:
- name: <container-name>
image: <image>
command: ["/bin/sh", "-c", "<your-command>"]
🧠 2️⃣ Analyzing Each Line You Remember
✅ a) Schedule every 30 minutes
“should run every thirty minutes” That means:
schedule: "*/30 * * * *"
✔️ Perfect — no issue here.
✅ b) Restart Policy
“pods should never restart” That’s clear:
restartPolicy: Never
✔️ You did it right.
✅ c) Completions = 96
“the job should complete 96 pods” That line directly refers to:
completions: 96
✔️ 100% correct.
⚠️ d) “Pods should terminate after 8 seconds”
Now, this is one of those tricky English phrases they love to use.
Here’s the rule of thumb:
| Phrase | Field | Explanation |
|---|---|---|
| “Pods should terminate after X seconds” | activeDeadlineSeconds | This defines how long a Job can run before K8s forcibly kills it. |
| “Pods should be deleted after X seconds of completion” | ttlSecondsAfterFinished | This defines how long the Job object stays after finishing successfully. |
💡 So:
- If it says terminate, they’re talking about runtime (→
activeDeadlineSeconds). - If it says delete after, they’re talking about cleanup (→
ttlSecondsAfterFinished).
👉 In your case, the phrase “terminate after 8 seconds” clearly points to runtime, so the correct field was:
activeDeadlineSeconds: 8
and not ttlSecondsAfterFinished. So here your guess was understandable but slightly wrong.
⚠️ e) “Number of retries” / “should not retry more than N times”
This one maps to:
backoffLimit: <value>
“The backoffLimit defines the number of retries before the job is considered failed.”
So your 136 should be placed as:
backoffLimit: 136
✔️ Perfect — this one you nailed!
⚠️ f) “job spec name” / “spec name should be xyz”
This one confuses many people — but here’s the golden rule:
| Where it applies | When you see it phrased as… | Correct placement |
|---|---|---|
| metadata.name under CronJob | “The job name should be <name>” | Top-level metadata.name: |
| metadata.name under jobTemplate’s Pod spec | “The pod created by this job should be named <name>” | Under template.metadata.name: |
| container name | “The container name should be <name>” | Under template.spec.containers[].name: |
So — if they wrote “Job spec name” — that’s referring to:
The
metadata.namefield inside the jobTemplate. (because they said job spec, not pod spec)
So correct placement:
jobTemplate:
metadata:
name: grp # from your example
✅ That’s right — your intuition that it referred to the Job name (not the pod) was correct.
🧠 3️⃣ Putting it All Together (Corrected Manifest)
Here’s how the correct CronJob should look based on what you remember:
apiVersion: batch/v1
kind: CronJob
metadata:
name: grp
namespace: <namespace-name>
spec:
schedule: "*/30 * * * *" # every 30 minutes
jobTemplate:
metadata:
name: grp # job name
spec:
completions: 96 # total completions
backoffLimit: 136 # number of retries
activeDeadlineSeconds: 8 # terminate after 8 seconds
template:
metadata:
name: grp-pod # optional (if asked)
spec:
restartPolicy: Never
containers:
- name: <container-name>
image: <image>
command: ["<command>"]
✅ 4️⃣ Summary of What You Got Right & Wrong
| Field | Your Attempt | Correct | Verdict |
|---|---|---|---|
| Schedule | every 30 min | ✅ | ✅ |
| Restart Policy | Never | ✅ | ✅ |
| Completions | 96 | ✅ | ✅ |
| Backoff Limit | 136 | ✅ | ✅ |
| Terminate after 8 seconds | ttlSecondsAfterFinished | ❌ should be activeDeadlineSeconds | |
| Job Spec Name | guessed as job name | ✅ correct intuition |
So overall: ⭐ ~90% correct manifest — only one small misinterpretation.
💬 5️⃣ Concept Summary
| Concept | Key Point |
|---|---|
completions | Number of successful pods to complete before job is marked done. |
backoffLimit | Max number of retries before marking job as failed. |
activeDeadlineSeconds | Maximum time job can run before being terminated. |
ttlSecondsAfterFinished | How long to keep job object after success/failure. |
restartPolicy | Always = keep restarting, Never = create new pod instead. |
❤️ 6️⃣ Final Verdict
You understood 90% of the logic correctly. Your only small error was mixing up “terminate after” (runtime limit) vs “delete after” (cleanup TTL). Everything else — schedule, completions, retries, names — perfect.