CronJob Management
Users can create timed tasks through forms based on image, or create and modify timed tasks through the YAML file template provided by Baidu AI Cloud, and conduct control and management to the container group (Pod) and events associated with timed tasks.
About CronJob
Cron Job is similar to crontab in Linux system. It runs the specified job in the specified time cycle, that is:
- Run once at a given point in time.
- Run periodically at a given point in time.
Typical Use Scenarios
- Schedule job runs at a given point in time, for example: Clean up log files after 5 minutes.
- Create a job that runs periodically, for example: Database backup every 1h, etc.
View Timed Tasks List
Enter "Product Services > Cloud Container Engine (CCE)">Select the Cluster, click "Working Load > Timed task" to enter the timed task page. Select the latest CCE cluster by default, and then select the "Default" namespace under the cluster. Load all scheduled job under the namespace, including:
- List data: Display the list information of all timed tasks, and create, delete, modify.
New Timed Task
Click "New Timed Task", users can choose to create a new timed task through forms or Yaml.
(1)Create through forms:
- Fill in the name of the timed task, and select cluster, name space and timing rule;
- Click the Add Container Configuration button, fill in the container name and image address, and click OK, the creation page displays the added container configuration information;
- Click Create to confirm the Yaml file generated based on the configuration information and complete the creation.
(2)Create through Yaml file:
- Select cluster and name space, fill in yaml file, and click OK.
- Copy: Copy the contents of the current yaml file.
- Cancel: Return to list page.
Field Interpretation
Schedule
spec.schedule
field is a required field of cronjob. Its value is a string in Cron format. For example: 0 * * * *
, or@hourly
. Kubernetes will create and run Jobs according to the scheduling time specified in this field.
Suspend
spec.suspend
field, optional field, default is false
. If set to true
, all subsequent job executions will be suspended.
Concurrency Policy
spec.concurrencyPolicy
field: Optional field. The default is Allow
. Specify how jobs created by Cronjob are executed concurrently. Only one of the following policies can be specified:
- Allow: Allow concurrent job running. If the previous job has not been completed, run the current job when it is turn for the current job to run.
- Forbid: Prohibit concurrent operation. If the previous job is not completed, skip it directly when the current job is running.
- Replace: Cancel the currently running Job and replace it with a new Job.
Job History Limit
.spec.successfulJobsHistoryLimit
and .spec.failedJobsHistoryLimit
are optional. They specify a limit on the number of completed and failed jobs that can be retained.
By default, there is no limit. All successful and failed jobs will be retained. However, when running a Cron Job, a lot of jobs will pile up quickly. It is recommended to set the values of these two fields. Set the limit value to 0, and Jobs of related types will not be retained after completion.
View Timed Task Details
Click the timed task name in any line of the list page to enter the timed task details page, which includes:
- Timed task details: Including basic information, active tasks and event list.
Modify Timed Tasks
On the timed task list page, click "Modify" in the timed task line to modify. After the modification, click "Update" to submit.
Delete Timed Task
On the timed task list page, check the timed task to delete, click "Delete", and then click "OK" after confirming the information.
Note: Currently, only single deletion is supported.