CronJobs
For more information, see the official documentation of Kubernetes.
You need to create a workspace, a project and a user (). The user must be invited to the project with the role of operator
. For more information, see .
Log in to the console as project-regular
. Go to Jobs of a project, choose CronJobs and click Create.
Step 2: Enter basic information
Enter the basic information. You can refer to the instructions below for each field. When you finish, click Next.
Name: The name of the CronJob, which is also the unique identifier.
Alias: The alias name of the CronJob, making resources easier to identify.
Schedule: It runs a Job periodically on a given time-based schedule. Please see for grammar reference. Some preset CRON statements are provided in KubeSphere to simplify the input. This field is specified by
.spec.schedule
. For this CronJob, enter*/1 * * * *
, which means it runs once per minute.-
- Maximum Start Delay (s). Specified by
.spec.startingDeadlineSeconds
in the manifest file, this optional field represents the maximum number of seconds that a ConJob can take to start if it misses the scheduled time for any reason. CronJobs that have missed executions will be counted as failed ones. If you do not specify this field, there is no deadline for the CronJob. - Successful Jobs Retained. Specified by in the manifest file, this field represents the number of successful CronJob executions to retain. This is a pointer to distinguish between explicit zero and not specified. It defaults to 3.
- Failed Jobs Retained. Specified by
.spec.failedJobsHistoryLimit
in the manifest file, this field represents the number of failed CronJob executions to retain. This is a pointer to distinguish between explicit zero and not specified. It defaults to 1. - Concurrency Policy. Specified by
.spec.concurrencyPolicy
, it represents how to treat concurrent executions of a Job:- Run Jobs concurrently (default): Run CronJobs concurrently.
- Skip new Job: Forbid concurrent runs and skip the next run if the previous run hasn’t finished yet.
- Skip old Job: Cancels currently running Job and replaces it with a new one.
- Maximum Start Delay (s). Specified by
Note
You can enable Edit YAML in the upper-right corner to see the YAML manifest of this CronJob.
Step 3: Strategy settings (Optional)
Please refer to .
Scroll down to Start Command and enter
/bin/sh,-c,date; echo "KubeSphere!"
in the box under Parameters.Click √ to finish setting the image and Next to continue.
Note
- This example CronJob prints . For more information about setting images, see Pod Settings.
- For more information about Restart Policy, see .
- You can skip Volume Settings and Advanced Settings for this tutorial. For more information, see Mount Volumes and in Deployments.
Step 5: Check results
Under the ConJobs tab, click this CronJob and go to the Job Records tab where you can see the information of each execution record. There are 3 successful CronJob executions as the field Successful Jobs Retained is set to 3.
Click any of them and you will be directed to the Job details page.
In Resource Status, you can inspect the Pod status. Click on the right and click to check the container log as shown below, which displays the expected output.
Operations
On the CronJob details page, you can manage the CronJob after it is created.
- Edit Information: Edit the basic information except
Name
of the CronJob. - Pause/Start: Pause or start the Cronjob. Pausing a CronJob will tell the controller to suspend subsequent executions, which does not apply to executions that already start.
- Delete: Delete the CronJob, and return to the CronJob list page.
Click the Job Records tab to view the records of the CronJob.
Metadata
Click the Metadata tab to view the labels and annotations of the CronJob.
Events
Click the Events tab to view the events of the CronJob.