Kubernetes Interview Prep: You Deployed 3 Pods, Only 1 Is Running. What Now?

2026-12-01来源 dev.toEnglish
Kubernetes Interview Prep: You Deployed 3 Pods, Only 1 Is Running. What Now?

If you sit through enough DevOps or Platform Engineering interviews, you are guaranteed to get hit with a scenario-based troubleshooting question. One of the absolute classics goes like this:

"You create a Deployment with replicas: 3. You check the cluster a few minutes later, and only 1 pod is Running, while the other 2 are stuck. What could be going wrong, and how do you fix it?"

Spotify

Interviewers love this question because it separates candidates who have only memorized kubectl flags from engineers who have actually been paged at 2:00 AM when a rollout stalls.

Notice the crucial detail in the prompt: 1 pod is actually working. That immediately rules out a bunch of global failures. Your YAML syntax isn't broken, the image tag isn't completely missing from the registry (unless it's a rolling update—more on that in a second), and the Kubernetes API server is alive.

Because 1 pod succeeded, your mental model should immediately shift toward capacity, scheduling constraints, node-specific issues, or rollout mechanics.

Let’s break down the exact root causes behind this scenario, followed by the step-by-step runbook you should walk your interviewer through to diagnose and resolve it.

Understanding the Root Causes: Why Did 1 Succeed and 2 Fail?

When you explain this in an interview, group your potential root causes logically. It shows structured thinking.

1. Resource Exhaustion (The Most Common Culprit)

Your cluster simply ran out of room. The Kubernetes scheduler placed the first pod onto a node that had just enough free CPU or memory to satisfy the pod's resources.requests. When it tried to schedule the remaining two pods, no nodes had enough allocatable capacity left. The remaining two pods will be stuck in a Pending state.

2. Strict Scheduling Constraints (podAntiAffinity, nodeSelector, or Taints)

Sometimes the nodes have plenty of CPU and RAM, but you’ve boxed the scheduler into a corner:

Hard podAntiAffinity: If your Deployment uses requiredDuringSchedulingIgnoredDuringExecution to ensure two pods of the same app never land on the same node, and you only have 1 worker node (or the other nodes are tainted/cordoned), the first pod takes the only available node and the other two are stranded in Pending.

odeSelector / nodeAffinity: Only one node in your cluster has the matching label (e.g., disktype=ssd), and that node only had enough resources or IP addresses for a single pod.

3. Node-Specific Failures (Bad Node or CNI IP Exhaustion)

Pod #1 landed on node-1 (healthy), while Pods #2 and #3 landed on node-2 (unhealthy). What makes a specific node fail?

Node Pressure / Kubelet Issues: node-2 might have DiskPressure, a dead container runtime, or broken DNS/network access to your private container registry (causing ImagePullBackOff on node-2 even though node-1 pulled the image fine).

IP Address Exhaustion: In cloud environments (like AWS EKS using the VPC CNI), each node has a hard limit on how many ENIs and private IP addresses it can hold. node-1 might have had 1 free IP left for Pod #1, while the rest of the cluster is out of IPs.

4. Stateful Storage Bottlenecks (ReadWriteOnce PVCs)

If your Deployment mounts a PersistentVolumeClaim (PVC) with an access mode of ReadWriteOnce (RWO)—such as standard AWS EBS or GCP Persistent Disks—that volume can only be mounted to a single node at a time. While pods on the same node can sometimes share it, if the scheduler places Pods #2 and #3 on different nodes, they will hang in ContainerCreating with a Multi-Attach error because the storage volume is locked to Pod #1's node.

5. A Stalled Rolling Update

If this wasn't a brand-new deployment, you might be looking at a broken RollingUpdate. Imagine you had 3 healthy pods running v1 of your app, and you deployed v2 (which has a bug and crashes on startup). Depending on your maxUnavailable and maxSurge settings, Kubernetes may have terminated two old pods and spun up new v2 pods that are now stuck in CrashLoopBackOff, leaving you with just 1 surviving v1 pod.

The Troubleshooting Runbook: Step-by-Step

When the interviewer asks, "How do you fix it?", don't jump straight to guessing. Walk them through your exact triage workflow.

Step 1: Check the Status and Location of All Pods

First, get the big picture. You need to know the exact STATUS of the two failing pods and which nodes they were assigned to.

kubectl get pods -l app=<your-app-label> -o wide 
  • If the 2 pods say Pending: The scheduler hasn't placed them on a node yet. Jump to Step 2.

  • If the 2 pods say ContainerCreating, ImagePullBackOff, or CrashLoopBackOff: They were scheduled to a node, and the Kubelet is failing to start them. Check the NODE column—are both failing pods on the exact same node?

Step 2: Inspect the Events on a Failing Pod

Never guess when Kubernetes will literally tell you what is wrong. Run describe on one of the broken pods and look straight at the Events table at the bottom:

kubectl describe pod <failing-pod-name> 

Here is how you read the clues in the Events output:

  • 0/3 nodes are available: 3 Insufficient cpu/memory → Capacity issue.

  • 0/3 nodes are available: 1 node(s) didn't match Pod's node affinity/selector, 2 node(s) had untolerated taint → Scheduling rule issue.

  • FailedAttachVolume: Multi-Attach error for volume → RWO storage issue (you should probably be using a StatefulSet with volumeClaimTemplates instead of a Deployment).

  • Failed to pull image ... rpc error → Registry auth or node network issue.

** Step 3: Check Node Health and Capacity (If Pending or Node-Isolated)**

If the events point to scheduling or a specific node acting up, inspect your cluster nodes:

kubectl get nodes kubectl describe node <node-name> 

Look at two sections in describe node:

  • Conditions: Check if MemoryPressure, DiskPressure, or NetworkUnavailable is True.

  • Allocated resources: Compare the total Requests against the node's Allocatable CPU and Memory. You might find your nodes are at 95% memory allocation, leaving no room for replicas 2 and 3.

Step 4: Check Container Logs (If CrashLoopBackOff)

If the pods are scheduled and pulling images fine, but crashing right after starting, it’s an application-level failure (or a LivenessProbe killing a slow-starting app). Check the logs of the crashed container instance:

kubectl logs <failing-pod-name> --previous 

Look for database connection timeouts (maybe your database has a max_connections limit that only allowed Pod #1 to connect!), missing environment variables, or port conflicts.

Applying the Fix

Once you've isolated the root cause from the steps above, state your remediation clearly:

  • For Resource Exhaustion: Right-size your pod's resources.requests (developers frequently over-request CPU/RAM), scale up your worker node group, or verify that your Cluster Autoscaler / Karpenter isn't hitting cloud quota limits.

  • For Affinity / Topology Deadlocks: Change hard podAntiAffinity (requiredDuringScheduling...) to soft anti-affinity (preferredDuringScheduling...) so Kubernetes prioritizes spreading pods across nodes, but will still co-locate them if node count is limited.

  • For a Bad Node: Cordon and drain the unhealthy node (kubectl drain --ignore-daemonsets) so Kubernetes reschedules the pods onto healthy nodes while you investigate the underlying VM.

For a Bad Rollout: Immediately roll back the deployment to restore all 3 replicas (kubectl rollout undo deployment/), then debug the broken v2 image in staging.

Key Takeaway for Your Interview

Don't give a one-word answer like "Maybe it's out of memory." Frame your answer around isolation:

"Since 1 pod is healthy, I know the manifest is valid and the control plane is working. I would immediately run kubectl get pods -o wide and kubectl describe pod on one of the failing replicas to determine whether this is a scheduler bottleneck (Pending due to CPU/memory, taints, or anti-affinity) or a node-level runtime failure (bad node, CNI IP limits, or volume attachment)."

Twitter

That single paragraph shows an interviewer that you understand Kubernetes architecture inside and out—and that you know how to stay calm and methodical when production is degraded.

原文:https://www.a8q9.cn/en/article/kubernetes-interview-prep-you-deployed-3-pods-only-1-is-running-what-now-c9f2d7.html

相关文章