Kubernetes Container Orchestration Pod Management 5 — Questions and Answers
Question 1: What does `kubectl cordon <node>` do to Pods already running on that node?
- Evicts all Pods immediately
- Marks the node unschedulable but does not affect existing Pods (Correct answer)
- Migrates Pods to other nodes automatically
- Pauses all Pods on the node
Correct answer: Marks the node unschedulable but does not affect existing Pods
kubectl cordon marks a node as unschedulable so no new Pods are placed there, but existing Pods continue running undisturbed.
Question 2: Which Kubernetes resource would you use to ensure exactly one Pod runs on every node in the cluster?
- Deployment with replicas equal to node count
- DaemonSet (Correct answer)
- StatefulSet
- ReplicaSet
Correct answer: DaemonSet
A DaemonSet automatically ensures one Pod replica runs on each eligible node, including new nodes added to the cluster.
Question 3: What is the function of `spec.containers[].lifecycle.preStop` hook?
- Runs a command when the container starts for the first time
- Executes a command or HTTP call immediately before the container is terminated (Correct answer)
- Defines a health check before traffic is routed to the container
- Cleans up volumes after the container exits
Correct answer: Executes a command or HTTP call immediately before the container is terminated
The preStop hook runs before the container receives SIGTERM, allowing it to complete in-flight requests or perform cleanup operations.
Question 4: A Pod is stuck in `Pending` state. Which of the following is NOT a likely cause?
- Insufficient CPU or memory on all nodes
- No node satisfies the Pod's node affinity rules
- The container's liveness probe is failing (Correct answer)
- No PersistentVolume is available to satisfy a PVC claim
Correct answer: The container's liveness probe is failing
Liveness probe failures affect running containers, not scheduling; a Pod must be running before probes are evaluated.
Question 5: How do you label an existing Pod with `env=production`?
- kubectl annotate pod <name> env=production
- kubectl label pod <name> env=production (Correct answer)
- kubectl set label pod <name> env=production
- kubectl patch pod <name> --label env=production
Correct answer: kubectl label pod <name> env=production
kubectl label modifies labels on existing Kubernetes objects; use --overwrite if the label key already exists.
Question 6: What happens when you define both `requests` and `limits` for a container with equal values?
- The container gets BestEffort QoS class
- The container gets Guaranteed QoS class (Correct answer)
- The container gets Burstable QoS class
- Kubernetes rejects the Pod spec as invalid
Correct answer: The container gets Guaranteed QoS class
When all containers in a Pod have equal CPU and memory requests and limits, the Pod is assigned the Guaranteed QoS class, the highest priority.
Question 7: Which field controls how a Pod's containers share a process namespace so they can see each other's processes?
- spec.hostPID: true
- spec.shareProcessNamespace: true (Correct answer)
- spec.containers[].pid: shared
- spec.processPolicy: shared
Correct answer: spec.shareProcessNamespace: true
Setting spec.shareProcessNamespace: true enables all containers in the Pod to share a single PID namespace, allowing them to signal each other's processes.
What does `kubectl cordon ` do to Pods already running on that node?