728x90
반응형
CronJob
정의
job 컨트롤러로 실행할 Application Pod를 주기적으로 반복해서 실행
Linux의 cronjob의 스케줄링 기능을 Job Controller에 추가한 API
다음과 같은 반복해서 실행하는 Job을 운영해야 할 때 사용
- Data Backup
- Send email
- Cleaning tasks
Cronjob Schedule: "0 3 1 * *"
- Minutes (from 0 to 59)
- Hours (from 0 to 23)
- Day of the month (from 1 to 31)
- Month (from 1 to 12)
- Day of the week (from 0 to 6)
생성
옵션 | 설명 |
concurrencyPolicy | Allow: 중복실행 가능, Forbid: 중복실행 불가 |
root@master:~# cat > cronjob-exam.yaml
apiVersion: batch/v1
kind: CronJob
metadata:
name: cronjob-exam
spec:
schedule: "* * * * *"
startingDeadlineSeconds: 300
concurrencyPolicy: Forbid
jobTemplate:
spec:
template:
spec:
containers:
- name: hello
image: busybox
args:
- /bin/sh
- "-c"
- echo Hello; sleep 80; echo Bye
restartPolicy: Never
root@master:~# kubectl create -f cronjob-exam.yaml
cronjob.batch/cronjob-exam created
조회
root@master:~# kubectl get cronjobs -o wide
NAME SCHEDULE SUSPEND ACTIVE LAST SCHEDULE AGE CONTAINERS IMAGES SELECTOR
cronjob-exam * * * * * False 0 <none> 42s hello busybox <none>
root@master:~# kubectl get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
cronjob-exam-27295769--1-m66lg 1/1 Running 0 17s 10.36.0.1 node1.example.com <none> <none>
삭제
root@master:~# kubectl delete cronjobs.batch cronjob-exam
cronjob.batch "cronjob-exam" deleted
728x90
반응형
'DevOps > Kubernetes' 카테고리의 다른 글
Kubernetes - Deployment (0) | 2021.11.25 |
---|---|
Kubernetes - DaemonSet (0) | 2021.11.25 |
Kubernetes -Job Controller (0) | 2021.11.23 |
Kubernetes - StatefulSet (0) | 2021.11.22 |
Kubernetes - ReplicaSet (0) | 2021.11.21 |