kkpareek
kkpareek

Reputation: 530

How to resolve pods failing due to exceeding pull rate limit from docker?

kubectl get all -n migration:

NAME                          READY   STATUS             RESTARTS   AGE
pod/nginx2-7b8667968c-zxtq7   0/1     ImagePullBackOff   0          5m38s

NAME                     READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/nginx2   0/1     1            0           5m38s

NAME                                DESIRED   CURRENT   READY   AGE
replicaset.apps/nginx2-7b8667968c   1         1         0       5m38s

kubectl describe pod nginx2-7b8667968c-zxtq7 -n migration:

Events:
  Type     Reason          Age                From               Message
  ----     ------          ----               ----               -------
  Normal   Scheduled       44s                default-scheduler  Successfully assigned migration/nginx2-7b8667968c-zxtq7 to k8s-master01
  Normal   SandboxChanged  33s                kubelet            Pod sandbox changed, it will be killed and re-created.
  Normal   Pulling         18s (x2 over 43s)  kubelet            Pulling image "nginx"
  Warning  Failed          14s (x2 over 34s)  kubelet            Failed to pull image "nginx": rpc error: code = Unknown desc = Error response from daemon: toomanyrequests: You have reached your pull rate limit. You may increase the limit by authenticating and upgrading: https://www.docker.com/increase-rate-limit
  Warning  Failed          14s (x2 over 34s)  kubelet            Error: ErrImagePull
  Normal   BackOff         3s (x4 over 32s)   kubelet            Back-off pulling image "nginx"
  Warning  Failed          3s (x4 over 32s)   kubelet            Error: ImagePullBackOff

Post-logging in with different docker account:

I can manually pull an image from docker using docker pull nginx

But while deploying a deployment, it again shows the same error.

Deployment yaml is as:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx2
  namespace: migration
spec:
  replicas: 1
  selector:
      matchLabels:
        name: nginx2
  template:
    metadata:
      labels:
        name: nginx2
    spec:
      containers:
      - name: nginx2
        imagePullPolicy: Always
        image: nginx
        ports:
        - containerPort: 3000
        volumeMounts:
          - name: game-demo
            mountPath: /usr/src/app/config
          - name: secret-basic-auth
            mountPath: /usr/src/app/secret
          - name: site-data2
            mountPath: /var/www/html
      volumes:
      - name: game-demo
        configMap:
          name: game-demo
      - name: secret-basic-auth
        secret:
          secretName: secret-basic-auth
      - name: site-data2
        persistentVolumeClaim:
          claimName: demo-pvc-claim2

Also, as the nginx image is present locally, I tried with modifying imagePullPolicy to Never as well as 'IfNotPresent'.

But nothing works. Please guide.

Upvotes: 0

Views: 1970

Answers (1)

OpenBSDNinja
OpenBSDNinja

Reputation: 1069

Here is your errror:

 Warning  Failed          14s (x2 over 34s)  kubelet            Failed to pull image "nginx": rpc error: code = Unknown desc = Error response from daemon: toomanyrequests: You have reached your pull rate limit. You may increase the limit by authenticating and upgrading: https://www.docker.com/increase-rate-limit

Basically docker hub is now becoming a paid thing if you exceed their rate limits. You can use the publically hosted image of "nginx" from Amazon's ECR instead:

docker pull public.ecr.aws/nginx/nginx:latest

That should be the same as the one you use using, just double check over here: https://gallery.ecr.aws/nginx/nginx

Upvotes: 2

Related Questions