File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1394,7 +1394,7 @@ Cron 时间表语法
13941394apiVersion: batch/v1
13951395kind: CronJob
13961396metadata:
1397- name: echo -cronjob
1397+ name: hello -cronjob
13981398spec:
13991399 schedule: "* * * * *" # Every minute
14001400 jobTemplate:
@@ -1408,7 +1408,20 @@ spec:
14081408 command: [for i in 9 8 7 6 5 4 3 2 1 ; do echo $i ; done]
14091409```
14101410
1411- TODO
1411+ 使用命令和 Job 也基本保持一致,这里就不过多赘述。
1412+
1413+ ``` shell
1414+ kubectl apply -f hello-cronjob.yaml
1415+ # cronjob.batch/hello-cronjob created
1416+
1417+ kubectl get cronjob
1418+ # NAME SCHEDULE SUSPEND ACTIVE LAST SCHEDULE AGE
1419+ # hello-cronjob * * * * * False 0 <none> 8s
1420+
1421+ kubectl get pods
1422+ # NAME READY STATUS RESTARTS AGE
1423+ # hello-cronjob-27694609--1-2nmdx 0/1 Completed 0 15s
1424+ ```
14121425
14131426## helm
14141427
Original file line number Diff line number Diff line change 11apiVersion : batch/v1
22kind : CronJob
33metadata :
4- name : echo -cronjob
4+ name : hello -cronjob
55spec :
66 schedule : " * * * * *" # Every minute
77 jobTemplate :
88 spec :
99 template :
1010 spec :
11- restartPolicy : OnFailure
11+ restartPolicy : Never
1212 containers :
1313 - name : echo
1414 image : busybox
15- command : ["echo", "Triggered by a CronJob"]
15+ command :
16+ - " bin/sh"
17+ - " -c"
18+ - " for i in 1 2 3 4 5 6 7 8 9 ; do echo $i ; done"
You can’t perform that action at this time.
0 commit comments