-
Notifications
You must be signed in to change notification settings - Fork 0
/
ysoftman-cronjob-test.yaml
34 lines (34 loc) · 1.07 KB
/
ysoftman-cronjob-test.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/
# https://kubernetes.io/docs/tasks/job/automated-tasks-with-cron-jobs/#jobs-history-limits
# apiVersion: batch/v1
# Kubernetes v1.21 이전에는 beta api 사용
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: ysoftman-cronjob-test
spec:
schedule: "*/5 * * * *"
successfulJobsHistoryLimit: 5
failedJobsHistoryLimit: 5
jobTemplate:
spec:
template:
spec:
containers:
- name: ysoftman-cronjob-test
image: busybox
imagePullPolicy: Always
command:
- /bin/sh
- -c
# for ((;;)) 는 sh 에서 지원하지 않아 while 사용
- date; echo "wait for 60s"; i=1; while [ $i -le 60 ]; do echo $i; sleep 1; i=$((i+1)); done; echo "job completed\!"
resources:
limits:
cpu: "500m"
memory: "200Mi"
requests:
cpu: "250m"
memory: "100Mi"
restartPolicy: OnFailure
backoffLimit: 1