Error codes & fixes: Kubernetes pod errors
9 Error codes & fixes commands: Kubernetes pod errors. Click a command to see what each part does.
Kubernetes pod errors9
kubectl logs <pod> -n <namespace> --previousCrashLoopBackOffContainer keeps crashing: read the crashed runWhat it means
Not a phase: the container starts, exits, and Kubernetes keeps restarting it with increasing back-off.
Usual causes & fixes
- App exits at startup: missing env var, bad config, failed DB connection (see the log).
- OOMKilled / exit 137: raise the memory limit.
- Liveness probe kills a slow-starting app: add a startupProbe.
- Wrong command/args in the pod spec.
Diagnose: what each part of the command does
logs <pod>container output--previousfrom the previous (crashed) container, not the one restarting now
kubectl describe pod <pod> -n <namespace> | grep -A 10 EventsImagePullBackOffImage cannot be pulled: read the pull errorWhat it means
ErrImagePull / ImagePullBackOff: the kubelet could not pull the image and is backing off.
Usual causes & fixes
- Wrong image name or tag (typos, tag never pushed).
- Private registry without
imagePullSecrets. - Registry rate limit (Docker Hub "toomanyrequests") or the node cannot reach the registry.
- Check from your machine:
docker pull <image>:<tag>.
Diagnose: what each part of the command does
describe podfull status| grep -A 10 Eventsjump to the Events and show 10 lines after
kubectl describe pod <pod> -n <namespace>PendingPod not scheduled: why?What it means
The pod is accepted but not running: usually it cannot be scheduled onto any node.
Usual causes & fixes
- "Insufficient cpu/memory": requests too high or the cluster is full (scale nodes or lower requests).
- "had untolerated taint" / node selector or affinity matches no node.
- PersistentVolumeClaim not bound:
kubectl get pvc -n <namespace>.
Diagnose: what each part of the command does
describe podlook at Events: FailedScheduling explains the reason
kubectl get configmap,secret -n <namespace>CreateContainerConfigErrorMissing ConfigMap or SecretWhat it means
The container config refers to something that does not exist (usually a ConfigMap/Secret or a key in it).
Usual causes & fixes
- Create the missing ConfigMap/Secret, or fix the name/key in
envFrom/valueFrom. - It exists in another namespace: they are namespaced.
Diagnose: what each part of the command does
get configmap,secretlist both kinds at once
- Create the missing ConfigMap/Secret, or fix the name/key in
kubectl get pod <pod> -n <namespace> -o jsonpath='{.status.containerStatuses[*].lastState.terminated.reason}'OOMKilledWas the container killed for memory?What it means
The container used more memory than its limit and the kernel killed it (exit code 137).
Usual causes & fixes
- Raise
resources.limits.memory(and requests) or fix the leak; compare withkubectl top pod. - JVM/Node.js heap configured larger than the container limit.
Diagnose: what each part of the command does
-o jsonpath=…print one fieldlastState.terminated.reasonwhy the previous container instance ended (OOMKilled, Error, Completed)
- Raise
kubectl get pods -A --field-selector=status.phase=FailedEvictedPods evicted from a nodeWhat it means
The kubelet removed pods because the node ran short of memory or disk (or for maintenance).
Usual causes & fixes
- Check node pressure:
kubectl describe node <node>→ Conditions (DiskPressure, MemoryPressure). - Clean them up:
kubectl delete pods -A --field-selector=status.phase=Failed. - Set requests/limits and ephemeral-storage limits so pods are scheduled realistically.
Diagnose: what each part of the command does
-Aall namespaces--field-selector=status.phase=Failedevicted pods end up as Failed
- Check node pressure:
kubectl get events -n <namespace> --sort-by=.lastTimestampContainerCreatingStuck creating: volume or network problemWhat it means
The pod is on a node but the container has not started yet.
Usual causes & fixes
- FailedMount / FailedAttachVolume: PVC, Secret or ConfigMap volume not available.
- CNI / network sandbox errors: networking plugin problem on that node.
- Very large image still pulling.
Diagnose: what each part of the command does
get eventswhat the scheduler/kubelet reported--sort-by=.lastTimestampnewest last
kubectl auth can-i <verb> <resource> -n <namespace> --as=<user>ForbiddenRBAC: am I allowed to do this?What it means
"… is forbidden: User … cannot …": the identity has no Role/ClusterRole binding for that action.
Usual causes & fixes
- Add a RoleBinding / ClusterRoleBinding for the user or service account.
- Wrong context or namespace:
kubectl config current-context.
Diagnose: what each part of the command does
auth can-iask the API server whether an action is allowed (yes/no)<verb> <resource>e.g. get pods, create deployments--as=<user>check for another user or service account (system:serviceaccount:<ns>:<name>)
kubectl config current-context && kubectl cluster-infoUnable to connect"Unable to connect to the server" / "Unauthorized"What it means
kubectl cannot reach or authenticate to the API server.
Usual causes & fixes
- Wrong context, VPN off, or a private API endpoint.
- Expired credentials: refresh the kubeconfig (
aws eks update-kubeconfig,az aks get-credentials,gcloud container clusters get-credentials).
Diagnose: what each part of the command does
config current-contextwhich cluster kubectl is pointing at&&thencluster-infotry to reach the API server
Nothing matches.
My DevOps Playbook by Angelo John Calleja