KCNA Pod Management & Scheduling 2 — Questions and Answers
Question 1: Which field in a Pod spec defines the list of init containers that run before app containers start?
- initContainers (Correct answer)
- setupContainers
- preContainers
- bootstrapContainers
Correct answer: initContainers
The `initContainers` field in the Pod spec lists containers that run to completion sequentially before any app containers start.
Question 2: A Pod is in 'Pending' state for a long time. Which kubectl command best helps diagnose why it hasn't been scheduled?
- kubectl describe pod <name> (Correct answer)
- kubectl logs <name>
- kubectl get pod <name> -o wide
- kubectl top pod <name>
Correct answer: kubectl describe pod <name>
`kubectl describe pod` shows Events section with scheduler messages explaining why a pod cannot be placed.
Question 3: What is the purpose of a PodDisruptionBudget (PDB)?
- Limit voluntary disruptions by ensuring a minimum number of pods remain available (Correct answer)
- Set CPU and memory limits for a pod
- Control how many pods a node can host
- Define restart policies for crashed pods
Correct answer: Limit voluntary disruptions by ensuring a minimum number of pods remain available
A PDB guarantees that a minimum number (or percentage) of pods stay available during voluntary disruptions like node drains.
Question 4: Which scheduling feature allows you to spread pods evenly across failure domains like zones?
- Topology Spread Constraints (Correct answer)
- Node Affinity
- Pod Anti-Affinity
- Taints and Tolerations
Correct answer: Topology Spread Constraints
Topology Spread Constraints use `topologyKey` to balance pod distribution across zones, nodes, or other topology domains.
Question 5: In a multi-container Pod, how do containers share the network namespace by default?
- All containers in a Pod share the same network namespace and IP (Correct answer)
- Each container gets its own IP address
- Containers communicate only via environment variables
- Containers use separate network namespaces bridged by CNI
Correct answer: All containers in a Pod share the same network namespace and IP
All containers within a Pod share one network namespace, meaning they share the same IP and can reach each other via localhost.
Question 6: Which Pod restart policy causes a container to restart only if it exits with a non-zero exit code?
- OnFailure (Correct answer)
- Always
- Never
- OnError
Correct answer: OnFailure
`restartPolicy: OnFailure` restarts the container only on non-zero exit codes, not on successful exits.
Question 7: What does setting `terminationGracePeriodSeconds: 0` on a Pod do?
- Forces immediate SIGKILL without waiting for graceful shutdown (Correct answer)
- Disables the liveness probe
- Removes the pod from the scheduler queue immediately
- Sets the pod to restart instantly after termination
Correct answer: Forces immediate SIGKILL without waiting for graceful shutdown
Setting `terminationGracePeriodSeconds` to 0 bypasses the graceful shutdown window and sends SIGKILL immediately.
Which field in a Pod spec defines the list of init containers that run before app containers start?