2020.08.07
1. K8s CronJob
https://kubernetes.io/ko/docs/concepts/workloads/controllers/cron-jobs/
2. CrobJob Test
$ cat cronjob.yaml
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: hello
namespace: yoosung-jeon
spec:
schedule: "*/1 * * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: hello
image: busybox
args:
- /bin/sh
- -c
- date; echo Hello from the Kubernetes cluster
restartPolicy: OnFailure
$ k get cronjobs.batch -n yoosung-jeon
NAME SCHEDULE SUSPEND ACTIVE LAST SCHEDULE AGE
hello */1 * * * * False 0 24s 16m
$ k get jobs.batch -n yoosung-jeon
NAME COMPLETIONS DURATION AGE
hello-1596766620 1/1 6s 2m26s
hello-1596766680 1/1 6s 86s
hello-1596766740 1/1 7s 26s
$ k get pod -n yoosung-jeon
NAME READY STATUS RESTARTS AGE
hello-1596766620-w8ssl 0/1 Completed 0 2m32s
hello-1596766680-h97dz 0/1 Completed 0 92s
hello-1596766740-fv2mt 0/1 Completed 0 31s
$
3. POD 실행 속도 측정
- CronJob hello는 매분 마다 실행 되며, 실행시 시간을 출력
- On-premise kubernetes (Dell r740)
$ k logs hello-1596766620-w8ssl -n yoosung-jeon | head -n 1
Fri Aug 7 02:17:09 UTC 2020
$ k logs hello-1596766680-h97dz -n yoosung-jeon | head -n 1
Fri Aug 7 02:18:09 UTC 2020
$ k logs hello-1596766740-fv2mt -n yoosung-jeon | head -n 1
Fri Aug 7 02:19:09 UTC 2020
$ k describe pod hello-1596766740-fv2mt -n yoosung-jeon | grep Event -A10
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 105s default-scheduler Successfully assigned yoosung-jeon/hello-1596766740-fv2mt to iap07
Normal Pulling 104s kubelet, iap07 Pulling image "busybox"
Normal Pulled 101s kubelet, iap07 Successfully pulled image "busybox"
Normal Created 101s kubelet, iap07 Created container hello
Normal Started 100s kubelet, iap07 Started container hello
$
- Google Cloud Engine 환경 (평균: 6초)
$ k logs hello-1596767400-kpghx | head -n 1
Fri Aug 7 02:30:06 UTC 2020
$ k logs hello-1596767460-z6dbk | head -n 1
Fri Aug 7 02:31:05 UTC 2020
$ k logs hello-1596767580-4j5v5 | head -n 1
Fri Aug 7 02:33:06 UTC 2020
$
'Kubernetes > Management' 카테고리의 다른 글
K8s 잡학다식 (0) | 2021.09.23 |
---|---|
Cert-manager with LetsEncrypt (DNS challenge) (1) | 2021.09.23 |
K8s - Slab memory leakage (2) | 2021.09.16 |
K8s - Node NotReady (0) | 2021.09.16 |
K8s - CNI not ready (0) | 2021.09.15 |
댓글