Skip to main content
Kubernetes coreLesson 6 of 13

Pulling Images from a Private Registry

A Pod asks for an image the registry will not hand out to strangers. Follow Pod → kubelet → runtime → registry and see where the login comes from, why it goes missing, and which error tells you what.

Imageregistry.example.com/shop/web:1.4.2
Credentialsnone
Pod statusContainerCreating
Namespace shopNamespace batchNode worker-1Pod webregistry.example.comServiceAccountdefaultSecret regcreddockerconfigjsonPod reportsame imagekubeletgathers credentialsRuntimecontainerd · CRI-OCredential pluginexec · short-livedPrivate registryregistry.example.comPull-through cachemirror for docker.ioDocker Hubpublic · rate limitedScheduledPullImage
RequestResponse / reportWatchAppears in a later step

What you will learn

  • Who pulls the image and why the registry says 401
  • imagePullSecrets of type kubernetes.io/dockerconfigjson
  • Pull secrets on a ServiceAccount and the namespace pitfall
  • Credential provider plugins for cloud registries
  • Rate limits, mirrors and credential checks for cached images

Pull errors and what they mean​

Event message or reasonCauseFix
401 Unauthorized, unauthorized, authorization failedNo credentials, or wrong ones, for this registryCheck the Secret's server name matches the image's registry exactly; check user and token
FailedToRetrieveImagePullSecretThe named pull secret is not in the Pod's namespaceCreate the Secret in that namespace, or fix the name
manifest unknown, not foundThe name or tag does not exist (or no image for this CPU architecture)Fix the image name or tag; check the registry UI
403 Forbidden, deniedLogged in, but this account may not read this repositoryGrant pull access to the account or token
429 Too Many Requests, toomanyrequestsRegistry rate limit, often anonymous Docker Hub pulls per IPLog in for pulls, use a pull-through cache, or mirror the image
i/o timeout, no such hostNetwork, DNS, proxy or firewall from the nodeTest from the node, e.g. crictl pull, and check egress
x509: certificate signed by unknown authorityThe node does not trust the registry's certificateInstall the CA on the node or in the runtime's registry config

Try it yourself​

kubectl create secret docker-registry regcred -n shop \
--docker-server=registry.example.com \
--docker-username=robot-pull --docker-password="$TOKEN" # type kubernetes.io/dockerconfigjson
kubectl get secret regcred -n shop -o jsonpath='{.data.\.dockerconfigjson}' | base64 -d # check the server name
kubectl patch serviceaccount default -n shop \
-p '{"imagePullSecrets":[{"name":"regcred"}]}' # new Pods get it automatically
kubectl get pod web -n shop -o jsonpath='{.spec.imagePullSecrets}{"\n"}' # what the Pod actually got
kubectl describe pod web -n shop | grep -A8 Events # read the Failed message
kubectl get events -A --field-selector reason=FailedToRetrieveImagePullSecret # secret missing in a namespace

Check yourself

  1. A Pod in namespace batch lists imagePullSecrets: regcred, and regcred exists in namespace shop. What happens?
  2. A rollout of 200 Pods on new nodes fails with 429 toomanyrequests from Docker Hub. Credentials were never needed for this public image. What helps most?
  3. Why does the kubelet check credentials for an image that is already on the node when KubeletEnsureSecretPulledImages is on?

Further reading: Images: using a private registry · Pull an Image from a Private Registry · Kubelet image credential provider · containerd registry hosts · How an Image Is Built and Run · Reading status in three layers and the troubleshooting order