Skip to main content

Executing Your First Job

The following tutorial walks you through how to create and execute an example JobConfig, as well as scheduling future Jobs.

Create a JobConfig

First, create an example JobConfig.

Install the example JobConfig from GitHub in a single one-liner:

kubectl create -f

For more explainable and runnable examples of JobConfigs, refer to

Executing the Job

Using the furiko command-line tool, execute the Job immediately as an ad-hoc execution:

furiko run example-jobconfig

You can view more details about the Job that was executed (press Tab to expand to the most recent job execution):

furiko get job example-jobconfig-

The following is a real-time demo of the above steps:

Enable automatic scheduling

The above example JobConfig is in ReadyDisabled state initially. Enable the JobConfig's schedule:

furiko enable example-jobconfig

The above cron expression is */5 * * * *, which means to run every 5 minutes. Wait for a while, and you should be able to see that the Job was automatically scheduled:

furiko list job --for=example-jobconfig

The above command lists all recent Jobs that were executed by the JobConfig. You should see something similar to the following output:

NAME                           PHASE       START TIME   RUN TIME   FINISH TIME
example-jobconfig-1670952000 Succeeded 16s 16s

Scheduling future executions

We can also schedule a future execution for the JobConfig:

furiko run example-jobconfig --at 2023-01-26T18:15:00Z

The timestamp above is dynamically generated to be at most 5 minutes in the future - copy the code block and try it out!

This queues the Job to be executed at a later time. List all jobs for the JobConfig again:

furiko list job --for=example-jobconfig

We should now see that the Job is in the Queued state.

NAME                           PHASE       START TIME   RUN TIME   FINISH TIME
example-jobconfig-5wpnv Queued

We can view more information about the Job before it has started running:

furiko get job example-jobconfig-5wpnv

We should see that it is indeed not yet started, and will be started in a few minutes time:

Name: example-jobconfig-5wpnv
Namespace: default
Type: Adhoc
Created: Wed, 14 Dec 2022 01:26:23 +08:00 (9 seconds ago)
Job Config: example-jobconfig
Start After: Wed, 14 Dec 2022 01:30:00 +08:00 (in 3 minutes)
Concurrency Policy: Enqueue

Phase: Queued
Reason: NotYetDue
Message: Job is queued to start no earlier than 2022-12-13 17:30:00 +0000 UTC

In the above example, notice that the job is scheduled to be started exactly at 01:30:00. By right, the cron schedule */5 * * * * should have also scheduled another Job at 01:30:00. However, since we are using the Forbid concurrency policy, this prevents multiple concurrent Jobs from being executed at the same time.

After waiting until 01:30:00, we can verify that there were indeed no other executions that started at the same time:

NAME                           PHASE       START TIME   RUN TIME   FINISH TIME
example-jobconfig-1670952300 Succeeded 6m 6m
example-jobconfig-1670952600 Succeeded 1m 1m