Failed to pull image toomanyrequests — You have reached your pull rate limit
Kubernetes pod creation fails with “Failed to pull image “nginx”: rpc error: code = Unknown desc = reading manifest latest in docker.io/library/nginx: toomanyrequests: You have reached your pull rate limit. You may increase the limit by authenticating and upgrading: https://www.docker.com/increase-rate-limit”
On November 20, 2020, rate limits anonymous and free authenticated use of Docker Hub went into effect. Anonymous and Free Docker Hub users are limited to 100 and 200 container image pull requests per six hours. You can read here for more detailed information.
Resolution to this issue is to pull image from docker registry by authenticating to the docker registry.
For docker container, use the following command to login to the docker registry to pull image.
$ docker login docker.io
For podman container, use the following command to login to the docker registry to pull image.
$ podman login docker.io
For cri-o container, use the following command to login to the docker registry to pull image.
$ crictl pull --creds <user>:<password> docker.io/library/nginx
For Kubernetes environment, we can create a secret to store the docker registry credential in a secret object and use the secret as a imagePullSecrets in our Pod definition file. Refer to the following configuration details.
In your Kubernetes namespace, create a secret using the following command:
$ kubectl create secret docker-registry regcred --docker-server=docker.io --docker-username=<replace your username> --docker-password=<replace with your password> --docker-email=<replace with your email address>
Now use the secret regcred in the pod definition file to create the Pod.
apiVersion: v1
kind: Pod
metadata:
name: nginx
spec:
containers:
- image: docker.io/nginx
name: nginx
imagePullSecrets:
- name: regcred