Skip to content

Error codes & fixes: Kubernetes pod errors

9 Error codes & fixes commands: Kubernetes pod errors. Click a command to see what each part does.

Index
9 items
Click a command to see what each part does.

Kubernetes pod errors9

  • kubectl logs <pod> -n <namespace> --previousCrashLoopBackOffContainer keeps crashing: read the crashed run

    What 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

    1. logs <pod>container output
    2. --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 error

    What 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

    1. describe podfull status
    2. | 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

    1. describe podlook at Events: FailedScheduling explains the reason
  • kubectl get configmap,secret -n <namespace>CreateContainerConfigErrorMissing ConfigMap or Secret

    What 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

    1. get configmap,secretlist both kinds at once
  • 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 with kubectl top pod.
    • JVM/Node.js heap configured larger than the container limit.

    Diagnose: what each part of the command does

    1. -o jsonpath=…print one field
    2. lastState.terminated.reasonwhy the previous container instance ended (OOMKilled, Error, Completed)
  • kubectl get pods -A --field-selector=status.phase=FailedEvictedPods evicted from a node

    What 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

    1. -Aall namespaces
    2. --field-selector=status.phase=Failedevicted pods end up as Failed
  • kubectl get events -n <namespace> --sort-by=.lastTimestampContainerCreatingStuck creating: volume or network problem

    What 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

    1. get eventswhat the scheduler/kubelet reported
    2. --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

    1. auth can-iask the API server whether an action is allowed (yes/no)
    2. <verb> <resource>e.g. get pods, create deployments
    3. --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

    1. config current-contextwhich cluster kubectl is pointing at
    2. &&then
    3. cluster-infotry to reach the API server

My DevOps Playbook by Angelo John Calleja

New runbook

GitHub not connected

Saving is handled by the site: the GitHub token is stored in Cloudflare, not in your browser. Enter the editor password (the EDITOR_PASSWORD secret) to unlock saving in this browser.

Saving commits to gelogrammer/My_DevOps_Playbook. Create a fine-grained token with access to only this repo andContents: Read and write, then paste it here. It is stored only in this browser.

src/content/docs/…