Skip to content

Commit

Permalink
[cron] feat: add cron document to README.md and add code.
Browse files Browse the repository at this point in the history
  • Loading branch information
guangzhengli committed Aug 28, 2022
1 parent 0ebc242 commit 597b98b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1394,7 +1394,7 @@ Cron 时间表语法
apiVersion: batch/v1
kind: CronJob
metadata:
name: echo-cronjob
name: hello-cronjob
spec:
schedule: "* * * * *" # Every minute
jobTemplate:
Expand All @@ -1408,7 +1408,20 @@ spec:
command: [for i in 9 8 7 6 5 4 3 2 1 ; do echo $i ; done]
```

TODO
使用命令和 Job 也基本保持一致,这里就不过多赘述。

```shell
kubectl apply -f hello-cronjob.yaml
# cronjob.batch/hello-cronjob created

kubectl get cronjob
# NAME SCHEDULE SUSPEND ACTIVE LAST SCHEDULE AGE
# hello-cronjob * * * * * False 0 <none> 8s

kubectl get pods
# NAME READY STATUS RESTARTS AGE
# hello-cronjob-27694609--1-2nmdx 0/1 Completed 0 15s
```

## helm

Expand Down
9 changes: 6 additions & 3 deletions cronJob/busybox.yaml → cronJob/hello-cronjob.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
apiVersion: batch/v1
kind: CronJob
metadata:
name: echo-cronjob
name: hello-cronjob
spec:
schedule: "* * * * *" # Every minute
jobTemplate:
spec:
template:
spec:
restartPolicy: OnFailure
restartPolicy: Never
containers:
- name: echo
image: busybox
command: ["echo", "Triggered by a CronJob"]
command:
- "bin/sh"
- "-c"
- "for i in 1 2 3 4 5 6 7 8 9 ; do echo $i ; done"

0 comments on commit 597b98b

Please sign in to comment.