Lab 8 - Cron Jobs¶
20 min Beginner
Problem¶
Your commander runs a simple status check on the X-Wing fleet by hand, every few minutes. To save time, you've been asked to automate it with a CronJob.
The CronJob must meet these requirements:
- The CronJob is named
xwing-cronjob. - It runs every two minutes, using the cron expression
*/2 * * * *. - It uses the image
registry.access.redhat.com/ubi9/ubi-minimal. -
The container runs this command, which prints the date and the fleet status:
-
Failed jobs are retried (
restartPolicy: OnFailure). - Only the last 3 successful jobs are kept.
Setup¶
Verification¶
-
Check the CronJob. After a couple of minutes,
LAST SCHEDULEshows when it last ran: -
You don't have to wait for the schedule. Trigger a run now by creating a Job from the CronJob's template:
-
Watch the scheduled Jobs appear every two minutes, then read the logs of all of them: