Skip to content

Commit 016367b

Browse files
Merge pull request #431 from GoingCharlie/cronjob
Add Cron VolcanoJob Concept
2 parents 2dc3789 + 124a995 commit 016367b

File tree

3 files changed

+429
-0
lines changed

3 files changed

+429
-0
lines changed

content/en/docs/cron_volcanoJob.md

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
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+
```

content/zh/docs/cron_volcanoJob.md

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
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+
### 定义
17+
Cron VolcanoJob, 简称cronvcjob,cronvj,是Volcano自定义的资源类型。用户现在可以根据预定义的调度计划定期创建和运行Volcano Job,类似于Kubernetes原生的CronJob,以实现批量计算任务(如AI和大数据)的定期执行。
18+
### 样例
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+
查看 Cron VolcanoJob
49+
```shell
50+
kubectl get cronvcjob
51+
```
52+
查看创建的 job 实例
53+
```shell
54+
kubectl get vcjob
55+
```
56+
### 关键字段
57+
* schedule
58+
59+
必需。用于volcano job 执行的 cron 计划字符串。使用标准 cron 格式。
60+
61+
* timeZone
62+
63+
可选。调度计划的时区名称。默认为 kube-controller-manager 的本地时区。
64+
65+
* concurrencyPolicy
66+
67+
可选。指定如何管理 Cron VolcanoJob 创建的 job 的并发执行。为下列规则中的一种:
68+
* Allow(默认):允许并发运行
69+
* Forbid:禁止并发运行,跳过新周期的执行
70+
* Replace:取消当前运行的 job,并用新的 job 替换它
71+
72+
<!-- -->
73+
74+
* startingDeadlineSeconds
75+
76+
可选。如果 job 错过其计划时间,启动 job 的截止时间(秒)。
77+
78+
* suspend
79+
80+
可选。如果设置为 true,所有后续执行将被暂停。
81+
82+
* jobTemplate
83+
84+
必需。用于创建 Volcano Job 的模板。包含完整的 Volcano Job 规范。
85+
86+
* successfulJobsHistoryLimit
87+
88+
可选。要保留的成功完成 job 的数量。默认为 3。
89+
90+
* failedJobsHistoryLimit
91+
92+
可选。要保留的失败完成 job 的数量。默认为 1。
93+
94+
<!-- -->
95+
96+
### 使用场景
97+
* 定期模型训练
98+
99+
每天凌晨自动启动分布式模型训练任务,利用集群空闲时段进行大规模机器学习训练。
100+
```shell
101+
apiVersion: batch.volcano.sh/v1alpha1
102+
kind: CronJob
103+
metadata:
104+
name: daily-model-training
105+
spec:
106+
schedule: "0 2 * * *" # 每天凌晨2点运行
107+
concurrencyPolicy: Forbid
108+
jobTemplate:
109+
spec:
110+
minAvailable: 4
111+
schedulerName: volcano
112+
tasks:
113+
- replicas: 1
114+
name: ps
115+
template:
116+
# 参数服务器配置
117+
- replicas: 3
118+
name: worker
119+
template:
120+
# 训练worker配置
121+
```
122+
123+
* 定时资源清理
124+
125+
每周日晚上清理临时数据和日志文件,释放集群存储空间。
126+
```shell
127+
apiVersion: batch.volcano.sh/v1alpha1
128+
kind: CronJob
129+
metadata:
130+
name: weekly-cleanup
131+
spec:
132+
schedule: "0 22 * * 0" # 每周日22点运行
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+
# 清理任务容器配置
143+
```

0 commit comments

Comments
 (0)