|
| 1 | ++++ |
| 2 | +title = "Cron VolcanoJob" |
| 3 | +date = 2025-11-19 |
| 4 | +lastmod = 2025-11-19 |
| 5 | + |
| 6 | +draft = false |
| 7 | +toc = true |
| 8 | +type = "docs" |
| 9 | + |
| 10 | +linktitle = "Cron VolcanoJob" |
| 11 | +[menu.docs] |
| 12 | + parent = "concepts" |
| 13 | + weight = 4 |
| 14 | ++++ |
| 15 | + |
| 16 | +### Introduction |
| 17 | +Cron VolcanoJob, also known as cronvcjob or cronvj, is a custom resource type in Volcano. Users can now periodically create and run Volcano Jobs based on predefined schedules, similar to Kubernetes native CronJobs, enabling scheduled execution of batch computing tasks (such as AI and big data workloads). |
| 18 | +### Example |
| 19 | +```shell |
| 20 | +apiVersion: batch.volcano.sh/v1alpha1 |
| 21 | +kind: CronJob |
| 22 | +metadata: |
| 23 | + name: volcano-cronjob-example |
| 24 | +spec: |
| 25 | + schedule: "*/5 * * * *" |
| 26 | + concurrencyPolicy: Forbid |
| 27 | + startingDeadlineSeconds: 60 |
| 28 | + successfulJobsHistoryLimit: 5 |
| 29 | + failedJobsHistoryLimit: 3 |
| 30 | + jobTemplate: |
| 31 | + spec: |
| 32 | + schedulerName: volcano |
| 33 | + tasks: |
| 34 | + - replicas: 1 |
| 35 | + name: "task-1" |
| 36 | + template: |
| 37 | + spec: |
| 38 | + containers: |
| 39 | + - name: busybox-container |
| 40 | + image: busybox:latest |
| 41 | + command: ["/bin/sh", "-c", "date; echo Hello from Volcano CronJob"] |
| 42 | + restartPolicy: OnFailure |
| 43 | + policies: |
| 44 | + - event: PodEvicted |
| 45 | + action: RestartJob |
| 46 | + minAvailable: 1 |
| 47 | +``` |
| 48 | +View Cron VolcanoJob |
| 49 | +```shell |
| 50 | +kubectl get cronvcjob |
| 51 | +``` |
| 52 | +View created job instances |
| 53 | +```shell |
| 54 | +kubectl get vcjob |
| 55 | +``` |
| 56 | +### Key Fields |
| 57 | +* schedule |
| 58 | + |
| 59 | + Required. The cron schedule string for Volcano Job execution. Uses standard cron format. |
| 60 | + |
| 61 | +* timeZone |
| 62 | + |
| 63 | + Optional. The time zone name for the schedule. Defaults to the local time zone of the kube-controller-manager. |
| 64 | + |
| 65 | +* concurrencyPolicy |
| 66 | + |
| 67 | + Optional. Specifies how to manage concurrent executions of jobs created by the Cron VolcanoJob. Must be one of the following: |
| 68 | + * Allow (default): Allow concurrent runs |
| 69 | + * Forbid: Skip new run if previous job hasn‘t completed |
| 70 | + * Replace: Cancel currently running job and start new |
| 71 | + |
| 72 | +<!-- --> |
| 73 | + |
| 74 | +* startingDeadlineSeconds |
| 75 | + |
| 76 | + Optional. Deadline in seconds for starting the job if it misses its scheduled time. |
| 77 | + |
| 78 | +* suspend |
| 79 | + |
| 80 | + Optional. If set to true, all subsequent executions will be suspended. |
| 81 | + |
| 82 | +* jobTemplate |
| 83 | + |
| 84 | + Required. The template for creating Volcano Jobs. Contains the complete Volcano Job specification. |
| 85 | + |
| 86 | +* successfulJobsHistoryLimit |
| 87 | + |
| 88 | + Optional. Number of successful finished jobs to retain. Defaults to 3. |
| 89 | + |
| 90 | +* failedJobsHistoryLimit |
| 91 | + |
| 92 | + Optional. Number of failed finished jobs to retain. Defaults to 1. |
| 93 | + |
| 94 | +<!-- --> |
| 95 | + |
| 96 | +### Usage |
| 97 | +* Periodic Model Training |
| 98 | + |
| 99 | +Automatically start distributed model training tasks daily during off-peak hours, utilizing cluster idle time for large-scale machine learning training. |
| 100 | +```shell |
| 101 | +apiVersion: batch.volcano.sh/v1alpha1 |
| 102 | +kind: CronJob |
| 103 | +metadata: |
| 104 | + name: daily-model-training |
| 105 | +spec: |
| 106 | + schedule: "0 2 * * *" # Run daily at 2 AM |
| 107 | + concurrencyPolicy: Forbid |
| 108 | + jobTemplate: |
| 109 | + spec: |
| 110 | + minAvailable: 4 |
| 111 | + schedulerName: volcano |
| 112 | + tasks: |
| 113 | + - replicas: 1 |
| 114 | + name: ps |
| 115 | + template: |
| 116 | + # Parameter server configuration |
| 117 | + - replicas: 3 |
| 118 | + name: worker |
| 119 | + template: |
| 120 | + # Training worker configuration |
| 121 | +``` |
| 122 | + |
| 123 | +* Scheduled Resource Cleanup |
| 124 | + |
| 125 | +Clean up temporary data and log files every Sunday evening to free up cluster storage space. |
| 126 | +```shell |
| 127 | +apiVersion: batch.volcano.sh/v1alpha1 |
| 128 | +kind: CronJob |
| 129 | +metadata: |
| 130 | + name: weekly-cleanup |
| 131 | +spec: |
| 132 | + schedule: "0 22 * * 0" # Run every Sunday at 10 PM |
| 133 | + timeZone: "Asia/Shanghai" |
| 134 | + jobTemplate: |
| 135 | + spec: |
| 136 | + minAvailable: 1 |
| 137 | + schedulerName: volcano |
| 138 | + tasks: |
| 139 | + - replicas: 1 |
| 140 | + name: cleanup |
| 141 | + template: |
| 142 | + # Cleanup task container configuration |
| 143 | +``` |
0 commit comments