Kubernetes ImagePullSecrets 因 ImagePullBackOff 而失败

Kubernetes ImagePullSecrets Failing with ImagePullBackOff

我无法让 Kubernetes 拉取我的私有 docker 镜像。

我的 default 命名空间中有一个名为 regcred 的 kubernetes 秘密,看起来像:

{"auths": {"index.docker.io": {"username": "Username", "password": "Password", "email": "random@email.com", "auth": "VXNlcm5hbWU6UGFzc3dvcmQ="}}}

授权是 Username:Password b64 编码。

这是我尝试创建的 pod,它每次都因 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

日志:

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

秘密看起来像:

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

知道我哪里出错了吗?

我的图片有问题,pod 规格需要:

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