You are viewing an old version of this page. View the current version.
Compare with Current View Page History
« Previous Version 10 Next »
목차
https://kubernetes.io/ko/docs/concepts/workloads/controllers/cron-jobs/
apiVersion: batch/v1 kind: CronJob metadata: name: hello-cronjob spec: schedule: "*/1 * * * *" # 매분마다 실행 concurrencyPolicy: Allow # 동시 실행 가능 jobTemplate: spec: template: spec: containers: - name: hello image: busybox:1.28 imagePullPolicy: IfNotPresent command: - /bin/sh - -c - date; echo Hello from the Kubernetes cluster restartPolicy: OnFailure
sansae@sansaeAir15m2 k8s-lab-workspace % k apply -f cronjob.yaml cronjob.batch/hello-cronjob created sansae@sansaeAir15m2 k8s-lab-workspace % k get all NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE service/kubernetes ClusterIP 10.0.0.1 <none> 443/TCP 7s NAME SCHEDULE SUSPEND ACTIVE LAST SCHEDULE AGE cronjob.batch/hello-cronjob */1 * * * * False 0 <none> 4s sansae@sansaeAir15m2 k8s-lab-workspace % k get pod NAME READY STATUS RESTARTS AGE hello-cronjob-28499961-hbpgl 0/1 Completed 0 119s hello-cronjob-28499962-rtts5 0/1 Completed 0 59s sansae@sansaeAir15m2 k8s-lab-workspace % k describe cronjob hello-cronjob Name: hello-cronjob Namespace: default Labels: <none> Annotations: <none> Schedule: */1 * * * * Concurrency Policy: Allow Suspend: False Successful Job History Limit: 3 Failed Job History Limit: 1 Starting Deadline Seconds: <unset> Selector: <unset> Parallelism: <unset> Completions: <unset> Pod Template: Labels: <none> Containers: hello: Image: busybox:1.28 Port: <none> Host Port: <none> Command: /bin/sh -c date; echo Hello from the Kubernetes cluster Environment: <none> Mounts: <none> Volumes: <none> Last Schedule Time: Sun, 10 Mar 2024 00:23:00 +0900 Active Jobs: <none> Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal SuccessfulCreate 2m26s cronjob-controller Created job hello-cronjob-28499961 Normal SawCompletedJob 2m19s cronjob-controller Saw completed job: hello-cronjob-28499961, status: Complete Normal SuccessfulCreate 86s cronjob-controller Created job hello-cronjob-28499962 Normal SawCompletedJob 83s cronjob-controller Saw completed job: hello-cronjob-28499962, status: Complete Normal SuccessfulCreate 26s cronjob-controller Created job hello-cronjob-28499963 Normal SawCompletedJob 22s cronjob-controller Saw completed job: hello-cronjob-28499963, status: Complete