FULL AI ANALYSIS

Kubernetes pods ImagePullBackOff after rotating registry credentials: namespace secret exists but serviceaccount not bound

Generated Oct 20, 2026, 9:41:02 AM

Analysis summary

Kubernetes will use imagePullSecrets from the pod spec or the serviceaccount bound to the pod. Creating a secret in the namespace does not automatically attach it to serviceaccounts or pods. The likely root causes: the default serviceaccount still references the old secret and pods created before serviceaccount patch retain the old token; Deployments without imagePullSecrets will not use new secret unless the serviceaccount is updated. ServiceAccount tokens and pod image pull logic may cache references until pods are recreated. The working fix is to patch the serviceaccount to reference the new secret and recreate pods or rollout the deployment.

Possible causes

Secret exists but not referenced by serviceaccount and pods lack imagePullSecrets in spec — Kubernetes won't auto-use namespace secrets

90%

ServiceAccount was patched but pods still reference old cached token; pods need to be recreated or serviceaccount token refreshed

55%

Secret type is wrong (not kubernetes.io/dockerconfigjson) or dockerconfigjson is malformed, causing auth failures

30%

Registry rate limiting or IP allowlist blocks new token while older connections succeed

15%

Suggested fixes

1

Diagnostic step 1

Verify secret type and content: kubectl get secret -n <ns> <secret> -o yaml and confirm type: kubernetes.io/dockerconfigjson and valid data.dockerconfigjson.

2

Diagnostic step 2

Patch the serviceaccount(s) used by your deployments to include the new secret: kubectl patch serviceaccount default -p '{"imagePullSecrets": [{"name": "ns-registry-secret"}]}' -n <ns>.

3

Diagnostic step 3

Trigger a rollout restart for deployments so pods are recreated and pick up updated serviceaccount: kubectl rollout restart deployment/<name> -n <ns>.

4

Diagnostic step 4

For immediate per-deployment fix without serviceaccount changes, add imagePullSecrets: to the pod spec and apply; this is reversible by removing the field.

5

Diagnostic step 5

If many namespaces/services are affected, script patching serviceaccounts and scheduling rolling restarts; test on one deployment first.