Kubernetes imagePullSecrets not working; getting image not found
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
When imagePullSecrets appears to be "not working," the secret is often not the real problem. Kubernetes can only use that secret to authenticate to the registry. If the image name, tag, registry hostname, secret namespace, or service-account wiring is wrong, you can still get errors that look like "image not found."
What imagePullSecrets Actually Does
imagePullSecrets provides registry credentials to the kubelet so it can pull a private image. It does not:
- fix an incorrect image name
- create the secret automatically in the right namespace
- override the service account if the pod does not reference it
A typical pod configuration looks like this:
That only works if regcred exists in the same namespace as the pod and contains valid credentials for registry.example.com.
Verify the Secret First
The usual command is:
Then confirm the secret exists in the right namespace:
It is also worth confirming the secret type. For registry pulls, Kubernetes expects a Docker config style secret, commonly kubernetes.io/dockerconfigjson. If the secret exists but contains the wrong structure, the pod still cannot authenticate to the registry correctly.
If the pod lives in my-namespace but the secret was created in default, the pull still fails. Namespace mismatches are one of the most common causes.
Check the Image Reference Carefully
Even with correct credentials, the image reference itself must be exact:
- registry hostname must match the real registry
- repository path must be correct
- tag must exist
- image case and separators must match exactly
Some private registries intentionally return a generic "not found" style error when authentication fails, which makes bad credentials and bad image names look similar. That is why you should validate both the secret and the image reference rather than assuming the error text tells the whole story.
Service Account Wiring Matters Too
Instead of putting imagePullSecrets on every pod, some teams attach the secret to the service account used by those pods:
Then the pod references that service account:
If the pod uses a different service account than the one you configured, the secret will never be used.
Read Pod Events, Not Just the Final Status
The most useful diagnostic output is usually:
Look at the event section. It often reveals whether the real problem is:
- authentication failure
- name resolution problem
- wrong image tag
- secret not found
That is much more actionable than staring only at ImagePullBackOff.
Common Pitfalls
- Creating the registry secret in the wrong namespace.
- Assuming
imagePullSecretscan compensate for a wrong image name or tag. - Forgetting that the secret must match the actual registry hostname used in the image reference.
- Attaching the secret to one service account while the pod runs under another.
- Reading "image not found" too literally when some registries use that message for auth failures too.
Summary
- '
imagePullSecretsonly supplies registry credentials; it does not fix image-reference mistakes.' - Make sure the secret exists in the same namespace as the pod or attached service account.
- Verify the registry hostname, repository path, and tag exactly.
- Check pod events with
kubectl describe podto see the real pull failure details. - Treat image-name issues, namespace wiring, and credential issues as separate checks, not one combined guess.
Related reading
- Kubernetes ingress-nginx LoadBalancer pointing to cloud bucket
- Kubernetes ingress an error on the server has prevented the request from succeeding
- Kubernetes ingress conditional routing
- Kubernetes Ingress controllers for wildcard url mapping
- kubernetes ingress service annotations
- kubernetes is it possible to add labels to individual containers?
- Kubernetes Ingress GCE keeps returning 502 error
- Kubernetes Ingress Path only works with /

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.