실습
Job
Job 생성
cat <<EOF | kubectl create -f - apiVersion: batch/v1 kind: Job metadata: name: sleepy spec: template: spec: containers: - name: resting image: busybox command: ["/bin/sleep"] args: ["3"] restartPolicy: Never EOF
생성된 Job 상태 확인
kubectl get job sleepy
Job에 발생한 Event 확인
kubectl describe job sleepy
생성된 Pod 확인
kubectl get pod -l job-name=sleepy
생성된 Job의 Manifest를 YAML 형식으로 출력
kubectl get job sleepy -o yaml | grep -A 14 -B 1 ^spec
Job 삭제
kubectl delete job sleepy
Job 생성
cat <<EOF | kubectl create -f - apiVersion: batch/v1 kind: Job metadata: name: sleepy spec: completions: 5 template: spec: containers: - name: resting image: busybox command: ["/bin/sleep"] args: ["3"] restartPolicy: Never EOF
생성된 Job 상태 확인
kubectl get job sleepy
생성된 Pod 확인
kubectl get pod -l job-name=sleepy
Job 삭제
kubectl delete job sleepy
Job 생성
cat <<EOF | kubectl create -f - apiVersion: batch/v1 kind: Job metadata: name: sleepy spec: completions: 5 parallelism: 2 template: spec: containers: - name: resting image: busybox command: ["/bin/sleep"] args: ["3"] restartPolicy: Never EOF
생성된 Job 상태 확인
kubectl get job sleepy
생성된 Pod 확인
kubectl get pod -l job-name=sleepy
Job 삭제
kubectl delete job sleepy
Job 생성
cat <<EOF | kubectl create -f - apiVersion: batch/v1 kind: Job metadata: name: sleepy spec: completions: 5 parallelism: 2 activeDeadlineSeconds: 15 template: spec: containers: - name: resting image: busybox command: ["/bin/sleep"] args: ["5"] restartPolicy: Never EOF
생성된 Job 상태 확인
kubectl get job sleepy
생성된 Pod 확인
kubectl get pod -l job-name=sleepy
Job에 발생한 Event 확인
kubectl describe job sleepy
Job 삭제
kubectl delete job sleepy
CronJob
CronJob 생성
cat <<EOF | kubectl create -f - apiVersion: batch/v1beta1 kind: CronJob metadata: name: sleepy spec: schedule: "*/1 * * * *" jobTemplate: spec: template: spec: containers: - name: resting image: busybox command: ["/bin/sleep"] args: ["5"] restartPolicy: Never EOF
생성된 CronJob 상태 확인
kubectl get cronjob sleepy
Job 목록 확인
kubectl get job
Pod 목록 확인
kubectl get pod -l job-name
CronJob 삭제
kubectl delete cronjob sleepy
CronJob 생성
cat <<EOF | kubectl create -f - apiVersion: batch/v1 kind: CronJob metadata: name: sleepy spec: schedule: "*/1 * * * *" jobTemplate: spec: template: spec: activeDeadlineSeconds: 10 containers: - name: resting image: busybox command: ["/bin/sleep"] args: ["30"] restartPolicy: Never EOF
생성된 CronJob 상태 확인
kubectl get cronjob sleepy
Job 목록 확인
kubectl get job
Pod 목록 확인
kubectl get pod -l job-name
CronJob 삭제
kubectl delete cronjob sleepy
Last updated