CronJob provide different ways to define tasks that run to completion and then stop. You can use a CronJob to run the same Job multiple times according a schedule.
A scheduled task (CronJob) is a type of workload controller in Kubernetes. You can create a CronJob through the web console or CLI to run a non-persistent program periodically or repeatedly, such as scheduled backups, scheduled clean-ups, or scheduled email dispatches.
Obtain the image address. The source of the images can be from the image repository integrated by the platform administrator through the toolchain or from third-party platforms' image repositories.
For the former, the Administrator typically assigns the image repository to your project, and you can use the images within it. If the required image repository is not found, please contact the Administrator for allocation.
If it is a third-party platform's image repository, ensure that images can be pulled directly from it in the current cluster.
Container Platform, navigate to Workloads > CronJobs in the left sidebar.
Click Create CronJob.
Select or Input an image, and click Confirm.
Note: You can filter images by selecting only when using images from the integrated image repository of this platform. For example, the integrated project name such as containers (docker-registry-projectname) includes the project name projectname from this platform and the project name containers from the image repository.
In the Cron Configuration section, configure the task execution method and associated parameters.
Execute Type:
Manual: Manual execution requires explicit manual triggering for each task run.
Scheduled: Scheduled execution configure the following scheduling parameters:
Parameter | Description |
---|---|
Schedule | Define the cron schedule using Crontab syntax. The CronJob controller calculates the next execution time based on the selected time zone. Notes:
|
Concurrency Policy | Specify how concurrent Job executions are handled (Allow , Forbid , or Replace per K8s spec). |
Job History Retention:
In the Job Configuration section, select the job type. A CronJob manages Jobs composed of Pods. Configure the Job template based on your workload type:
Parameter | Description |
---|---|
Job Type | Select Job completion mode (Non-parallel , Parallel with fixed completion count , or Indexed Job per K8s Job patterns). |
Backoff Limit | Set maximum retry attempts before marking a Job as failed. |
In the Pod section, please refer to Creating Deployment - Configure Pod
In the Container section, please refer to Creating Deployment - Configure Containers
Click Create.
Locate the CronJob resource:
Initiate ad-hoc execution:
Monitor execution status:
Status | Description |
---|---|
Pending | Job created but not yet scheduled |
Running | Job Pod(s) are actively executing |
Succeeded | All Pods completed successfully (exit code 0) |
Failed | At least one Pod terminated unsuccessfully (non-zero exit code) |
Verify Job details: