3
Monitor and wait for the job to succeed. Throughout this practice test remember to increase the 'BackOffLimit' to prevent the job from quitting before it succeeds.
Check out the documentation page about the BackOffLimit property.

그저 6이 나와야 성공하는 job이니까 backoffLimit의 숫자를 높이면 된다고 생각했는데 계속 오류가 났음
[풀이]
2번에서 job을 만들때 내가 만든 yaml파일은
apiVersion: batch/v1
kind: Job
metadata:
name: throw-dice-job
spec:
template:
spec:
containers:
- name: throw-dice-job
image: kodekloud/throw-dice
command: ["6"]
restartPolicy: Never
backoffLimit: 15
이거였는데 command는 필요하지 않았다.
apiVersion: batch/v1
kind: Job
metadata:
name: throw-dice-job
spec:
template:
spec:
containers:
- name: throw-dice-job
image: kodekloud/throw-dice
restartPolicy: Never
backoffLimit: 15
이렇게 만들고 Succeeded가 생길때까지 기다리면 됨
controlplane ~ ➜ k describe job throw-dice-job
Name: throw-dice-job
Namespace: default
Selector: batch.kubernetes.io/controller-uid=93e7eb2a-fb96-4265-ac1a-9bf7fd191a9d
Labels: batch.kubernetes.io/controller-uid=93e7eb2a-fb96-4265-ac1a-9bf7fd191a9d
batch.kubernetes.io/job-name=throw-dice-job
controller-uid=93e7eb2a-fb96-4265-ac1a-9bf7fd191a9d
job-name=throw-dice-job
Annotations: <none>
Parallelism: 1
Completions: 1
Completion Mode: NonIndexed
Suspend: false
Backoff Limit: 15
Start Time: Sun, 26 Jan 2025 07:03:04 +0000
Completed At: Sun, 26 Jan 2025 07:03:38 +0000
Duration: 34s
Pods Statuses: 0 Active (0 Ready) / 1 Succeeded / 2 Failed
Pod Template:
Labels: batch.kubernetes.io/controller-uid=93e7eb2a-fb96-4265-ac1a-9bf7fd191a9d
batch.kubernetes.io/job-name=throw-dice-job
controller-uid=93e7eb2a-fb96-4265-ac1a-9bf7fd191a9d
job-name=throw-dice-job
Containers:
throw-dice-job:
Image: kodekloud/throw-dice
Port: <none>
Host Port: <none>
Environment: <none>
Mounts: <none>
Volumes: <none>
Node-Selectors: <none>
Tolerations: <none>
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal SuccessfulCreate 50s job-controller Created pod: throw-dice-job-w7ht2
Normal SuccessfulCreate 39s job-controller Created pod: throw-dice-job-sm7z6
Normal SuccessfulCreate 19s job-controller Created pod: throw-dice-job-sdt2n
Normal Completed 16s job-controller Job completed
5
Update the job definition to run as many times as required to get 2 successful 6's.
Delete existing job and create a new one with the given spec. Monitor and wait for the job to succeed.
Job Name: throw-dice-job
Image Name: kodekloud/throw-dice
Completions: 2
Job Succeeded: True
정답
completions의 위치는 spec 밑에...
apiVersion: batch/v1
kind: Job
metadata:
name: throw-dice-job
spec:
completions: 2
backoffLimit: 25 # This is so the job does not quit before it succeeds.
template:
spec:
containers:
- name: throw-dice
image: kodekloud/throw-dice
restartPolicy: Never