Cloud Computing

Kubernetes pods show ImagePullBackOff when pulling image from private registry after credential rotation

techtony
3w ago
Environment

Environment

Kubernetes cluster using imagePullSecrets referenced in deployments; private registry uses basic auth with a Docker config JSON stored as a kubernetes.io/dockerconfigjson secret. Registry uses TLS with internal CA.

Symptoms

Symptoms

kubectl get pods shows ImagePullBackOff. kubectl describe pod shows events mentioning Failed to pull image and unauthorized or x509 errors. Deployment was working before credential rotation.

Observations

Observations

The secret exists in the namespace, but after rotating registry credentials and recreating secret, pods still fail. docker pull from a bastion using new creds succeeds when logged in manually, but kubelet nodes still report errors. ServiceAccount may not reference the updated secret.

Already attempted

Already attempted

Reapplied deployment YAML and restarted kubelet on a single node. Recreated imagePullSecret with kubectl create secret docker-registry. Tried docker login from node rootless and manually pulled the image (success). Pods still show ImagePullBackOff.

Diagnostic steps

Diagnostic steps

  1. Describe the pod to read the pull error: kubectl describe pod <pod> -n <ns> and look under Events for 'Failed to pull image' messages and exact error text.
  • What the result means: If error mentions 'unauthorized' or 'denied', credentials are wrong or not provided. If error mentions x509 or certificate names, it's a TLS trust problem on the node.
  1. Check secret and its annotation: kubectl get secret <secret-name> -n <ns> -o yaml and confirm type: kubernetes.io/dockerconfigjson and data['.dockerconfigjson'] present. Also verify the pod spec uses imagePullSecrets or the serviceAccount references the secret.
  • What the result means: If secret missing or wrong type, recreate with kubectl create secret docker-registry and ensure it's in the same namespace. If pod/serviceAccount not referencing it, add the reference and redeploy.
  1. On a node that attempted the pull, try docker pull <registry>/<image>:tag (or crictl pull for containerd) after logging into the registry using the same credentials: docker login <registry> && docker pull ...
  • What the result means: If manual pull succeeds, node can reach the registry and credentials are correct for that node. If manual pull fails with TLS errors, address CA/trust on nodes.
  1. Verify serviceAccount binding: kubectl get serviceaccount <sa> -n <ns> -o yaml and confirm imagePullSecrets includes the secret. Also check default serviceAccount if pod doesn't specify one.
  • What the result means: If serviceAccount lacks the secret, pods using it won't receive credentials. Adding the secret to the serviceAccount and recreating pods resolves the binding.
  1. Check node kubelet logs for image pull errors: sudo journalctl -u kubelet --since '10m' | grep -i 'pull' or check container runtime logs (containerd/cri) for pull errors.
  • What the result means: Node logs often contain detailed TLS or auth errors that help decide whether the fix is secret, CA distribution, or node-level cache needing kubelet/containerd restart.
Confirmed fixes

Confirmed fixes

No fix has been independently verified for this scenario. Treat the causes below as diagnostic hypotheses.

Question

Question

How to determine whether Kubernetes is using the updated secret, whether nodes trust the registry TLS chain, and how to safely restore image pulls cluster-wide?

COMMUNITY RESPONSES

Verified community troubleshooting

0 replies

No answers yet..

Showing 0 of 0 community responses
AI DIAGNOSTICS

Incident analysis

Updated 3w ago• Trouble ID

Most likely causes

imagePullSecret exists but not referenced by the pod's serviceAccount or pod spec 60%
Secret recreated in the wrong namespace or with incorrect type/format 45%
Node TLS trust issue for registry CA (x509: certificate signed by unknown authority) 40%

Summary

ImagePullBackOff from private registries after credential rotation is usually due to (a) secret not referenced by the serviceaccount or pod spec, (b) secret created in a different namespace, (c) kubelet/node-level caching or old docker-credential helpers, or (d) TLS verification failing on nodes. Diagnosis should confirm secret contents, binding, node trust, and attempt a direct docker pull on nodes.

Suggested Fixes

Diagnostic step 1
Describe the pod to read the pull error: kubectl describe pod <pod> -n <ns> and look under Events for 'Failed to pull image' messages and exact error text. Result meaning: If error mentions 'unauthorized' or 'denied', credentials are wrong or not provided. If error mentions x509 or certificate names, it's a TLS trust problem on the node.
Diagnostic step 2
Check secret and its annotation: kubectl get secret <secret-name> -n <ns> -o yaml and confirm type: kubernetes.io/dockerconfigjson and data['.dockerconfigjson'] present. Also verify the pod spec uses imagePullSecrets or the serviceAccount references the secret. Result meaning: If secret missing or wrong type, recreate with kubectl create secret docker-registry and ensure it's in the same namespace. If pod/serviceAccount not referencing it, add the reference and redeploy.
Diagnostic step 3
On a node that attempted the pull, try docker pull <registry>/<image>:tag (or crictl pull for containerd) after logging into the registry using the same credentials: docker login <registry> && docker pull ... Result meaning: If manual pull succeeds, node can reach the registry and credentials are correct for that node. If manual pull fails with TLS errors, address CA/trust on nodes.

Continue troubleshooting

Matched from the title, description and tags