'Kubernetes ImagePullSecrets Failing with ImagePullBackOff

I can't get Kubernetes to pull my private docker image.

I have a kubernetes secret called regcred in my default namespace looking like:

{"auths": {"index.docker.io": {"username": "Username", "password": "Password", "email": "[email protected]", "auth": "VXNlcm5hbWU6UGFzc3dvcmQ="}}}

The auth is Username:Password b64 encoded.

This is the pod I am trying to create which just fails everytime with ImagePullBackOff.

apiVersion: v1
kind: Pod
metadata:
  name: private-reg
spec:
  containers:
  - name: private-reg-container
    image: index.docker.io/jor2/hello-world:latest
  imagePullSecrets:
  - name: regcred

logs:

Error from server (BadRequest): container "private-reg-container" in pod "private-reg" is waiting to start: image can't be pulled
Events:
  Type     Reason     Age                From               Message
  ----     ------     ----               ----               -------
  Normal   Scheduled  67s                default-scheduler  Successfully assigned default/private-reg to 10.144.195.222
  Normal   Pulling    20s (x3 over 66s)  kubelet            Pulling image "index.docker.io/jor2/hello-world"
  Warning  Failed     17s (x3 over 63s)  kubelet            Failed to pull image "index.docker.io/jor2/hello-world": rpc error: code = NotFound desc = failed to pull and unpack image "docker.io/jor2/hello-world:latest": failed to unpack image on snapshotter overlayfs: unexpected media type text/html for sha256:361849f1befca621043d13cca4e9bee74861754154556e149340a455e53d1d35: not found
  Warning  Failed     17s (x3 over 63s)  kubelet            Error: ErrImagePull
  Normal   BackOff    3s (x3 over 63s)   kubelet            Back-off pulling image "index.docker.io/jor2/hello-world"
  Warning  Failed     3s (x3 over 63s)   kubelet            Error: ImagePullBackOff

The secret looks like:

apiVersion: v1
data:
  .dockerconfigjson: eyJhdXRocyI6IHsiaHR0cHM6Ly9pbmRleC5kb2NrZXIuaW8vdjEvIjogeyJ1c2VybmFtZSI6ICJVc2VybmFtZSIsICJwYXNzd29yZCI6ICJQYXNzd29yZCIsICJlbWFpbCI6ICJyYW5kb21AZW1haWwuY29tIiwgImF1dGgiOiAiVlhObGNtNWhiV1U2VUdGemMzZHZjbVE9In19fQo=
kind: Secret
metadata:
  creationTimestamp: "2022-04-25T18:59:03Z"
  managedFields:
  - apiVersion: v1
    fieldsType: FieldsV1
    fieldsV1:
      f:data:
        .: {}
        f:.dockerconfigjson: {}
      f:type: {}
    manager: kubectl-create
    operation: Update
    time: "2022-04-25T18:59:03Z"
  name: regcred
  namespace: default
  resourceVersion: "270226"
  uid: bbb1310b-421a-4c93-8488-498e7a52095f
type: kubernetes.io/dockerconfigjson

Any idea where I am going wrong?



Solution 1:[1]

It was a problem with my image and the pod spec needed to be:

apiVersion: v1
kind: Pod
metadata:
  name: private-reg
spec:
  containers:
  - name: private-reg-container
    image: jor2/hello-world:latest
  imagePullSecrets:
  - name: regcred

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 jor2