Kubernetes Container Orchestration Pod Management 3 — Questions and Answers
Question 1: What is an init container and when does it run relative to app containers?
- A container that runs after app containers to clean up resources
- A container that runs to completion before app containers start (Correct answer)
- A sidecar container that runs alongside app containers
- A container that initializes node-level configurations
Correct answer: A container that runs to completion before app containers start
Init containers run sequentially to completion before any app containers in the Pod start, making them ideal for setup tasks.
Question 2: A Pod has multiple containers. Which command executes a command in a specific container?
- kubectl exec <pod> --container=<name> -- <cmd> (Correct answer)
- kubectl exec <pod> -n <name> -- <cmd>
- kubectl run <pod> --target=<name> -- <cmd>
- kubectl attach <pod> --select=<name>
Correct answer: kubectl exec <pod> --container=<name> -- <cmd>
The --container (or -c) flag specifies which container inside a multi-container Pod to target with kubectl exec.
Question 3: What is the effect of setting `imagePullPolicy: Never` on a container?
- Kubernetes always pulls the latest image tag
- Kubernetes only uses an image already present on the node and never pulls from a registry (Correct answer)
- Kubernetes caches the image for 24 hours before re-pulling
- Kubernetes skips image validation checks
Correct answer: Kubernetes only uses an image already present on the node and never pulls from a registry
imagePullPolicy: Never forces Kubernetes to use only locally cached images, causing the Pod to fail if the image is not already on the node.
Question 4: Which Pod phase indicates that all containers have terminated successfully?
- Completed
- Succeeded (Correct answer)
- Terminated
- Done
Correct answer: Succeeded
The Succeeded phase means all containers in the Pod have exited with a zero exit code and will not be restarted.
Question 5: What is the role of a `sidecar container` in a Pod?
- It replaces the main container if it fails
- It runs alongside the main container to provide supporting functionality like logging or proxying (Correct answer)
- It initializes shared volumes before the main container starts
- It monitors the main container and restarts it on failure
Correct answer: It runs alongside the main container to provide supporting functionality like logging or proxying
Sidecar containers share the same network namespace and volumes as the main container, extending its capabilities without modifying its image.
Question 6: How does Kubernetes handle a Pod that fails its liveness probe repeatedly?
- The Pod is evicted from the node
- The failing container is restarted according to the restartPolicy (Correct answer)
- The Pod is moved to another node
- The Pod is marked Unschedulable
Correct answer: The failing container is restarted according to the restartPolicy
When a liveness probe fails beyond its threshold, kubelet restarts the specific container, not the entire Pod.
Question 7: What does `kubectl top pod` display?
- The Pod's resource requests and limits from its spec
- The real-time CPU and memory usage of each Pod (Correct answer)
- The historical peak resource consumption
- The Pod's QoS class and priority
Correct answer: The real-time CPU and memory usage of each Pod
kubectl top pod shows live resource usage (CPU and memory) collected from the metrics-server, not the configured requests/limits.
What is an init container and when does it run relative to app containers?