0
0
Kubernetesdevops~20 mins

Jobs and CronJobs for batch processing in Kubernetes - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Batch Processing Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
1:30remaining
Output of a Kubernetes Job status command
What is the output of the following command after the Job completes successfully?

kubectl get jobs batch-job -o jsonpath='{.status.succeeded}'
A0
BError: job not found
Cnull
D1
Attempts:
2 left
💡 Hint
The .status.succeeded field shows how many pods completed successfully.
🧠 Conceptual
intermediate
1:30remaining
Understanding CronJob schedule format
Which of the following CronJob schedule strings runs a job every day at 3:30 AM?
A30 3 * * *
B3 30 * * *
C0 3 * * *
D30 15 * * *
Attempts:
2 left
💡 Hint
Cron format is: minute hour day month weekday
Configuration
advanced
2:30remaining
Correct YAML for a Kubernetes Job with restartPolicy
Which YAML snippet correctly defines a Kubernetes Job with a pod restart policy of 'Never'?
A
apiVersion: batch/v1
kind: Job
metadata:
  name: example-job
spec:
  template:
    spec:
      containers:
      - name: example
        image: busybox
        command: ['echo', 'hello']
      restartPolicy: Always
B
apiVersion: batch/v1
kind: Job
metadata:
  name: example-job
spec:
  template:
    spec:
      containers:
      - name: example
        image: busybox
        command: ['echo', 'hello']
      restartPolicy: Never
C
apiVersion: batch/v1
kind: Job
metadata:
  name: example-job
spec:
  restartPolicy: Never
  template:
    spec:
      containers:
      - name: example
        image: busybox
        command: ['echo', 'hello']
D
apiVersion: batch/v1
kind: Job
metadata:
  name: example-job
spec:
  template:
    spec:
      containers:
      - name: example
        image: busybox
        command: ['echo', 'hello']
Attempts:
2 left
💡 Hint
The restartPolicy must be under spec.template.spec and set to 'Never' for Jobs.
Troubleshoot
advanced
2:00remaining
Troubleshooting a CronJob that never runs
A CronJob is created with schedule '0 25 * * *'. What is the likely reason it never runs?
AThe CronJob needs a manual trigger to start the first run.
BThe minute field '0' is invalid; minutes must be 1-59.
CThe hour field '25' is invalid; hours must be 0-23.
DThe CronJob requires a restartPolicy of Always to run.
Attempts:
2 left
💡 Hint
Check the valid ranges for cron schedule fields.
🔀 Workflow
expert
3:00remaining
Order the steps to create and verify a Kubernetes CronJob
Put these steps in the correct order to create and verify a Kubernetes CronJob that runs a batch task every hour.
A1,2,3,4
B2,1,3,4
C1,3,2,4
D3,1,2,4
Attempts:
2 left
💡 Hint
Think about writing, applying, then checking status and logs.