Question 12
Domain 2: Application Deployment and WorkloadsWhich Kubernetes Job configuration in namespace `q19` creates `batch-job` so it runs `busybox:latest` with `sh -c 'echo Processing batch item'`, completes 5 times, and runs up to 2 Pods simultaneously?
Correct answer: A
Explanation
This Job uses `apiVersion: batch/v1` and `kind: Job` to create `batch-job` in namespace `q19`, matching the required Kubernetes resource. `completions: 5` means it must finish five times, and `parallelism: 2` allows up to two Pods to run at once, while the container runs `busybox:latest` with `sh -c "echo Processing batch item"`.
Why each option is right or wrong
A. apiVersion: batch/v1 kind: Job metadata: name: batch-job namespace: q19 spec: completions: 5 parallelism: 2 template: spec: restartPolicy: Never containers: - name: batch-job image: busybox:latest command: ["sh", "-c", "echo Processing batch item"]
Kubernetes Jobs are defined under `batch/v1` with `kind: Job`, and the object metadata must place it in the `q19` namespace to scope it correctly. Under the Job spec, `completions: 5` requires five successful completions, while `parallelism: 2` caps concurrent Pods at two; the Pod template then specifies `busybox:latest` and the exact `sh -c` command, with `restartPolicy: Never` required for Job-managed Pods.
B. apiVersion: batch/v1 kind: Job metadata: name: batch-job namespace: q19 spec: completions: 2 parallelism: 5 template: spec: restartPolicy: OnFailure containers: - name: batch-job image: busybox:latest command: ["sh", "-c", "echo Processing batch item"]
C. apiVersion: batch/v1 kind: Deployment metadata: name: batch-job namespace: q19 spec: replicas: 5 template: spec: restartPolicy: Never containers: - name: batch-job image: busybox:latest command: ["sh", "-c", "echo Processing batch item"]
D. apiVersion: batch/v1 kind: Job metadata: name: batch-job namespace: q19 spec: completions: 5 parallelism: 2 template: spec: restartPolicy: Always containers: - name: batch-job image: busybox:latest command: ["sh", "-c", "echo Processing batch item"]