Back-off restarting failed container
Cause: The container starts, exits, and kubelet restarts it with a growing delay. The restart count is a symptom; the exit code and the previous container's logs hold the cause.
kubectl describe pod <pod> -n <ns>
kubectl logs <pod> -n <ns> --previous
kubectl get pod <pod> -n <ns> -o jsonpath='{.status.containerStatuses[0].lastState.terminated}'
Fix: Read Last State: exit 1 is an app error (config, missing env var), 137 is OOM or a failed liveness probe, 127 is a wrong command.
Full diagnosis & fix: CrashLoopBackOff →Failed to pull image ... not found / unauthorized / no such host
Cause: The node can't fetch the image: a wrong tag, a private registry without credentials, or a registry the node can't reach.
kubectl describe pod <pod> -n <ns> | grep -A10 Events
kubectl get pod <pod> -n <ns> -o jsonpath='{.spec.containers[*].image}'
kubectl get secret <pull-secret> -n <ns> -o jsonpath='{.data.\.dockerconfigjson}' | base64 -d
Fix: Match the event text: "not found" means fix the tag, "unauthorized" means add imagePullSecrets in the same namespace, "no such host" means check node DNS or egress.
Full diagnosis & fix: ImagePullBackOff / ErrImagePull →Last State: Terminated, Reason: OOMKilled, Exit Code: 137
Cause: The container went over its memory limit and the kernel killed it. 137 means 128 + SIGKILL (9).
kubectl describe pod <pod> -n <ns> | grep -A5 'Last State'
kubectl top pod <pod> -n <ns> --containers
kubectl get pod <pod> -n <ns> -o jsonpath='{.spec.containers[*].resources}'
Fix: Check whether usage climbs steadily (a leak, fix the app) or spikes at load (raise the limit). For JVM and Node, cap the heap below the container limit.
Full diagnosis & fix: OOMKilled (exit code 137) →STATUS Pending, no node assigned
Cause: The scheduler can't place the pod, or a volume it needs isn't bound yet. The events always say which.
kubectl describe pod <pod> -n <ns> | grep -A10 Events
kubectl get nodes -o wide
kubectl get pvc -n <ns>
Fix: Insufficient cpu/memory means lower requests or add nodes. Taints or affinity mismatches mean fix the selector. Unbound PVC means fix the StorageClass.
Full diagnosis & fix: Pod stuck in Pending →0/3 nodes are available: 3 Insufficient memory / had untolerated taint
Cause: Every node was ruled out. The message counts nodes per reason, so read each clause.
kubectl get events -n <ns> --field-selector reason=FailedScheduling
kubectl describe nodes | grep -A8 'Allocated resources'
kubectl get nodes -o custom-columns=NAME:.metadata.name,TAINTS:.spec.taints
Fix: Requests are scheduled, not actual usage. Right-size requests, add a toleration, or let the cluster autoscaler add capacity.
Full diagnosis & fix: FailedScheduling →waiting for first consumer / no persistent volumes available for this claim
Cause: No StorageClass, no default StorageClass, a CSI driver that isn't running, or WaitForFirstConsumer waiting on a pod.
kubectl describe pvc <pvc> -n <ns>
kubectl get storageclass
kubectl get pods -n kube-system | grep -i csi
Fix: Set storageClassName to a class that exists (or mark one as default) and confirm the CSI controller pods are healthy.
Full diagnosis & fix: PersistentVolumeClaim Pending →The node was low on resource: memory / ephemeral-storage
Cause: The kubelet evicted pods to protect the node under memory or disk pressure. BestEffort pods go first.
kubectl get pods -A --field-selector status.phase=Failed
kubectl describe node <node> | grep -A6 Conditions
kubectl delete pods -A --field-selector status.phase=Failed
Fix: Set requests and limits (including ephemeral-storage), stop writing logs or temp files to the container filesystem, and clean up evicted pods.
Full diagnosis & fix: Pod Evicted →STATUS NotReady, Kubelet stopped posting node status
Cause: The kubelet stopped reporting: kubelet or container runtime down, the CNI broken, disk or memory pressure, or the node lost its network.
kubectl describe node <node> | grep -A10 Conditions
journalctl -u kubelet -n 100 --no-pager
systemctl status containerd
Fix: Fix what the kubelet log names (certificate expiry, runtime socket, CNI not initialized, full disk). On managed clusters, replacing the node is often fastest.
Full diagnosis & fix: Node NotReady →Error: configmap "x" not found / couldn't find key y in Secret
Cause: The kubelet can't build the container config. Almost always a ConfigMap, Secret, or key reference that doesn't exist in that namespace.
kubectl describe pod <pod> -n <ns> | grep -i error
kubectl get configmap,secret -n <ns>
kubectl get secret <name> -n <ns> -o jsonpath='{.data}'
Fix: Create the missing object or key in the pod's namespace, or mark the reference optional: true if the app can start without it.
Full diagnosis & fix: CreateContainerConfigError →connection refused / timed out calling a ClusterIP Service
Cause: The selector matches no pods, the targetPort is wrong, the pods aren't Ready, or a NetworkPolicy blocks traffic.
kubectl get endpointslices -n <ns> -l kubernetes.io/service-name=<svc>
kubectl get svc <svc> -n <ns> -o yaml | grep -A5 -E 'selector|ports'
kubectl run tmp --rm -it --image=busybox -- wget -qO- http://<svc>.<ns>:<port>
Fix: Empty endpoints means the selector labels don't match the pods. Endpoints exist but nothing answers means targetPort doesn't match containerPort.
Full diagnosis & fix: Service not reachable →502 Bad Gateway or 504 Gateway Timeout from the ingress controller
Cause: 502: the controller reached no healthy backend (wrong port, pods not Ready, upstream reset). 504: the backend answered too slowly.
kubectl describe ingress <ing> -n <ns>
kubectl logs -n ingress-nginx deploy/ingress-nginx-controller --tail=100
kubectl get endpointslices -n <ns> -l kubernetes.io/service-name=<svc>
Fix: For 502, fix the Service port and readiness. For 504, raise proxy-read-timeout via annotation only after confirming the backend is slow, not stuck.
Full diagnosis & fix: Ingress 502 Bad Gateway / 504 Gateway Timeout →could not resolve host / i/o timeout on lookup
Cause: CoreDNS pods are down or overloaded, a NetworkPolicy blocks port 53, or ndots:5 makes external lookups slow.
kubectl run dnstest --rm -it --image=busybox:1.36 -- nslookup kubernetes.default
kubectl get pods -n kube-system -l k8s-app=kube-dns
kubectl logs -n kube-system -l k8s-app=kube-dns --tail=50
Fix: Restore CoreDNS, allow UDP and TCP 53 egress, and use fully qualified names (trailing dot) or a lower ndots for external hosts.
Full diagnosis & fix: DNS resolution fails in pods →too many open files / failed to create fsnotify watcher
Cause: The node's inotify limits or the container's file descriptor limit ran out, often from log tailers or file watchers.
sysctl fs.inotify.max_user_instances fs.inotify.max_user_watches
kubectl exec <pod> -- sh -c 'ulimit -n'
kubectl exec <pod> -- sh -c 'ls /proc/1/fd | wc -l'
Fix: Raise fs.inotify.max_user_instances and max_user_watches on nodes (DaemonSet or node config), and fix descriptor leaks in the app.
Full diagnosis & fix: Too many open files (Kubernetes) →Exit Code: 1 / 126 / 127 / 137 / 139 / 143
Cause: The exit code is the fastest clue to why a container stopped. Codes above 128 mean a signal: subtract 128 to get it.
kubectl get pod <pod> -n <ns> -o jsonpath='{.status.containerStatuses[*].lastState.terminated.exitCode}'
kubectl describe pod <pod> -n <ns> | grep -E 'Exit Code|Reason'
Fix: Use the exit code table below to go from the number to the likely cause.
Full diagnosis & fix: Kubernetes exit codes reference →TARGETS <unknown>/80% / FailedGetResourceMetric: unable to get metrics for resource cpu
Cause: The HPA can't read metrics. Either metrics-server is missing or unhealthy, or the target pods have no CPU/memory requests, so utilization (usage divided by request) can't be computed.
kubectl get hpa -n <ns>
kubectl describe hpa <hpa> -n <ns>
kubectl get apiservice v1beta1.metrics.k8s.io
kubectl top pods -n <ns>
Fix: Install or repair metrics-server and set resources.requests on every container in the target pods, sidecars included. If it scales up but never down, that is the 300-second scale-down stabilization window working as designed.
Full diagnosis & fix: HPA not scaling (<unknown> targets) →Error from server (Forbidden): pods is forbidden: User "system:serviceaccount:<ns>:<sa>" cannot list resource "pods" in API group "" in the namespace "<ns>"
Cause: No Role or ClusterRole bound to that identity grants that verb on that resource. The message names the user, verb, resource, API group and namespace, so it is the exact spec for the fix.
kubectl auth can-i list pods -n <ns> --as=system:serviceaccount:<ns>:<sa>
kubectl auth can-i --list -n <ns> --as=system:serviceaccount:<ns>:<sa>
kubectl get rolebindings,clusterrolebindings -A -o wide | grep <sa>
Fix: Create a Role with exactly that verb, resource and API group, and bind it to the identity in that namespace. Binding cluster-admin makes the error go away and creates a much bigger problem.
Full diagnosis & fix: RBAC Forbidden →Readiness probe failed: HTTP probe failed with statuscode: 503 / Liveness probe failed: Get "http://10.0.1.7:8080/healthz": context deadline exceeded
Cause: A failing readiness probe removes the pod from Service endpoints (READY 0/1, no restarts). A failing liveness probe restarts the container, which often looks like CrashLoopBackOff with exit 137 or 143. Usual roots: wrong path or port, the 1-second default timeoutSeconds on a slow endpoint, or a health check that calls the database.
kubectl describe pod <pod> -n <ns> | grep -iA3 probe
kubectl get pod <pod> -n <ns> -o jsonpath='{.spec.containers[0].livenessProbe}'
kubectl port-forward pod/<pod> 8080:<port> & curl -sv localhost:8080/healthz
kubectl get endpointslices -n <ns> -l kubernetes.io/service-name=<svc>
Fix: Point liveness at a cheap endpoint that never checks downstream dependencies, raise timeoutSeconds, and give slow-booting apps a startupProbe instead of a long initialDelaySeconds.
Full diagnosis & fix: Readiness / liveness probe failed →Waiting for deployment "<name>" rollout to finish: 1 out of 3 new replicas have been updated... / error: deployment "<name>" exceeded its progress deadline
Cause: The new pods never become Ready, so the Deployment stops progressing after progressDeadlineSeconds (600 by default). The old ReplicaSet keeps serving, so this is a readiness, image or capacity problem in the new pods.
kubectl rollout status deploy/<name> -n <ns>
kubectl describe deploy <name> -n <ns> | grep -A6 Conditions
kubectl get rs -n <ns> -l app=<label>
kubectl rollout undo deploy/<name> -n <ns>
Fix: Debug the newest ReplicaSet's pods like any failing pod (describe, logs --previous). If users are affected, run rollout undo first and fix forward after.
Full diagnosis & fix: Rollout stuck (ProgressDeadlineExceeded) →