0
0
Kubernetesdevops~10 mins

Jobs and CronJobs for batch processing in Kubernetes - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to specify the kind of Kubernetes resource for a batch job.

Kubernetes
apiVersion: batch/v1
kind: [1]
metadata:
  name: example-job
Drag options to blanks, or click blank then click option'
ADeployment
BPod
CService
DJob
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Pod' or 'Deployment' instead of 'Job'.
2fill in blank
medium

Complete the code to set the schedule for a CronJob to run every day at midnight.

Kubernetes
apiVersion: batch/v1
kind: CronJob
metadata:
  name: daily-job
spec:
  schedule: "[1]"
Drag options to blanks, or click blank then click option'
A0 12 * * *
B0 6 * * *
C0 0 * * *
D0 18 * * *
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing 12 with midnight, or using wrong hour values.
3fill in blank
hard

Fix the error in the container image name for the Job spec.

Kubernetes
spec:
  template:
    spec:
      containers:
      - name: batch-task
        image: [1]
      restartPolicy: Never
Drag options to blanks, or click blank then click option'
Abusybox:latest
Bbusybox
Cubuntu
Dnginx:latest
Attempts:
3 left
💡 Hint
Common Mistakes
Using image names without tags or incomplete names.
4fill in blank
hard

Fill both blanks to create a Job spec that runs a command and never restarts the pod.

Kubernetes
spec:
  template:
    spec:
      containers:
      - name: task
        image: busybox:latest
        command: ["[1]", "[2]"]
      restartPolicy: Never
Drag options to blanks, or click blank then click option'
Aecho
Bsleep
CHello, World!
D3600
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'sleep' with a string message or mixing command and arguments.
5fill in blank
hard

Fill all three blanks to define a CronJob that runs a backup script every hour at minute 15.

Kubernetes
apiVersion: batch/v1
kind: CronJob
metadata:
  name: hourly-backup
spec:
  schedule: "[1]"
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: backup
            image: alpine:latest
            command: ["[2]", "[3]", "backup.sh"]
          restartPolicy: OnFailure
Drag options to blanks, or click blank then click option'
A15 * * * *
B/bin/sh
C-c
Dbackup.sh
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing cron syntax or command arguments.