ExamPilot Global home

CKAD lab · Create and verify a scheduled workload

An app should write a maintenance message once an hour.

ExamPilot graduation owl

Initial conditions

Use an empty namespace lab. Save the manifest as schedule.yaml.

Objective

Write a CronJob with Forbid concurrency and validate a manual Job created from it.

Hint

The CronJob holds the template. Use kubectl create job to test it immediately.

Solution manifest

apiVersion: batch/v1
kind: CronJob
metadata:
  name: housekeeping
spec:
  schedule: "0 * * * *"
  concurrencyPolicy: Forbid
  jobTemplate:
    spec:
      template:
        spec:
          restartPolicy: Never
          containers:
          - name: check
            image: busybox:1.36
            command: ["echo", "maintenance complete"]

Solution commands

kubectl -n lab apply -f schedule.yaml
kubectl -n lab create job quick-check --from=cronjob/housekeeping

Validate the result

kubectl -n lab wait --for=condition=Complete job/quick-check --timeout=60s
kubectl -n lab logs job/quick-check

The manual Job runs the same template. Forbid applies to concurrent schedules from the same CronJob.

Common mistakes

A Deployment maintains running replicas and is not an hourly task scheduler.

Free official documentation · Verified 26 November 2026

Use your own disposable Kubernetes environment.