Kubernetes in production · core
What kubectl apply does, and CrashLoopBackOff and ImagePullBackOff
A Deployment goes through the API server, controllers, scheduler and kubelet. Pod failure states are symptoms, and the exit reason and events tell the real cause.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
- kubectl sends the object to the API server: authentication, authorization (RBAC), admission (mutating then validating) and storage in etcd.
- Controllers watch the API: the Deployment controller creates a ReplicaSet and the ReplicaSet controller creates Pods. The scheduler filters and scores nodes (requests, taints, affinity, volume zones) and binds each pod to a node.
- The kubelet asks the container runtime through CRI to pull the image and start containers. The CNI plugin sets up the pod network. Readiness passing adds the pod to the Service endpoints.
- CrashLoopBackOff is a state, not the error: the container keeps exiting and the kubelet waits longer between restarts (up to 5 minutes).
- Debug order: kubectl get pods, describe pod (last state, exit code, events), logs --previous, events sorted by time, then the diff of manifests and config.
- Exit codes: 1 is an app error, 137 is killed (OOM or a failed liveness probe), 126 or 127 is a bad or missing command, and 0 with restartPolicy Always still restarts.
- ImagePullBackOff: describe the pod to see the registry answer: not found, unauthorized (pull secret or IAM for ECR), toomanyrequests (rate limit) or timeout (network, NAT or missing endpoint).
- Old nodes have images cached, so pull problems show first on new nodes during a scale-up. Fix with a registry cache or mirror, VPC endpoints and a pre-pulled image.
The red pen
Common traps: mistake → fix
Mistake: CrashLoopBackOff is the error
Fix: it is a restart delay; find the exit reason.
Mistake: kubectl logs shows the crash
Fix: use --previous for the crashed container.
Mistake: Pull errors appear on every node
Fix: cached images hide them on old nodes.
Easy to hard
Questions interviewers ask, easy to hard
- What happens when you run kubectl apply on a Deployment?
- New pods are in CrashLoopBackOff. What do you do?
- What does exit code 137 mean?
- Pods get ImagePullBackOff only on new nodes. Why?
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.