k8s ImagePullBackOff的原因

kubernetes如果遇到ImagePullBackOff该如何排查呢?

状态

$ kubectl get pods
NAME               READY   STATUS             RESTARTS       AGE
sentry-web         0/1     ImagePullBackOff   0              4m55s

ImagePullBackOff代表拉取镜像时被阻塞,最常见的原因是镜像不存在。

原因

使用 kubectl describe pod sentry-web 查看启动细节:

$ kubectl describe pod sentry-web
Name:         sentry-web
Namespace:    default
...省略
Events:
  Type     Reason     Age                    From               Message
  ----     ------     ----                   ----               -------
  Normal   Scheduled  4m50s                  default-scheduler  Successfully assigned default/sentry-web to kind-control-plane
  Normal   Pulling    3m14s (x4 over 4m51s)  kubelet            Pulling image "sentry-self-hosted-local"
  Warning  Failed     3m10s (x4 over 4m44s)  kubelet            Failed to pull image "sentry-self-hosted-local": rpc error: code = Unknown desc = failed to pull and unpack image "docker.io/library/sentry-self-hosted-local:latest": failed to resolve reference "docker.io/library/sentry-self-hosted-local:latest": pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed
  Warning  Failed     3m10s (x4 over 4m44s)  kubelet            Error: ErrImagePull
  Warning  Failed     2m44s (x6 over 4m43s)  kubelet            Error: ImagePullBackOff
  Normal   BackOff    2m29s (x7 over 4m43s)  kubelet            Back-off pulling image "sentry-self-hosted-local"

发现原因是

failed to pull and unpack image "docker.io/library/sentry-self-hosted-local:latest"

结合细节

看我的配置文件:

kind: Pod
apiVersion: v1
metadata:
  name: sentry-web
  labels:
    app: sentry
spec:
  hostNetwork: true
  containers:
    - name: sentry-web
      image: sentry-self-hosted-local

这个镜像只有我本地有,但是他还是去拉远程,原因是我没写tag.

为了让错误更明显,改为只使用本地:

spec:
  hostNetwork: true
  containers:
    - name: sentry-web
      image: sentry-self-hosted-local:latest
      imagePullPolicy: Never  # or IfNotPresent
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值