创建Pod时k8s镜像拉取失败

一、使用yaml文件创建一个pod,发现pod无法起来,报错:ImagePullBackOff

[root@iZwz9gwr0avfoncztr5y2jZ ~]# kubectl get pod 
NAME                     READY   STATUS             RESTARTS   AGE
nginx-855696b796-mb6cv   1/1     Running            0          3d23h
test-nginx               0/1     ImagePullBackOff   0          3m47s

yaml文件

apiVersion: v1
kind: Pod
metadata:
  name: test-nginx
spec:
  containers:
  - image: hlqlinux/hlq-test/nginx-v2
    name: test-nginx
    volumeMounts:
    - mountPath: /test-pd
      name: test-volume
  volumes:
  - name: test-volume
    hostPath:
      path: /data

二、查询创建状态

[root@iZwz9gwr0avfoncztr5y2jZ ~]# kubectl describe pod test-nginx
Name:         test-nginx
Namespace:    my-namespace
Priority:     0
Node:         izwz96awf0ghla99pm85ksz/172.17.69.66
Start Time:   Tue, 07 Dec 2021 09:26:44 +0800
Labels:       <none>
Annotations:  kubernetes.io/change-cause: kubectl create --filename=hostpath.yaml --record=true
Status:       Pending
IP:           10.244.1.12
Containers:
  test-nginx:
    Container ID:   
    Image:          hlqlinux/hlq-test/nginx-v2
    Image ID:       
    Port:           <none>
    Host Port:      <none>
    State:          Waiting
      Reason:       ImagePullBackOff
    Ready:          False
    Restart Count:  0
    Environment:    <none>
    Mounts:
      /test-pd from test-volume (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-p4m8p (ro)
Conditions:
  Type              Status
  Initialized       True 
  Ready             False 
  ContainersReady   False 
  PodScheduled      True 
Volumes:
  test-volume:
    Type:          HostPath (bare host directory volume)
    Path:          /data
    HostPathType:  
  default-token-p4m8p:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-p4m8p
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                 node.kubernetes.io/unreachable:NoExecute for 300s
Events:
  Type     Reason     Age                     From                              Message
  ----     ------     ----                    ----                              -------
  Normal   Scheduled  10m                     default-scheduler                 Successfully assigned my-namespace/test-nginx to izwz96awf0ghla99pm85ksz
  Normal   Pulling    8m23s (x4 over 10m)     kubelet, izwz96awf0ghla99pm85ksz  Pulling image "hlqlinux/hlq-test/nginx-v2"
  Warning  Failed     8m20s (x4 over 9m59s)   kubelet, izwz96awf0ghla99pm85ksz  Failed to pull image "hlqlinux/hlq-test/nginx-v2": rpc error: code = Unknown desc = Error response from daemon: pull access denied for hlqlinux/hlq-test/nginx-v2, repository does not exist or may require 'docker login'
  Warning  Failed     8m20s (x4 over 9m59s)   kubelet, izwz96awf0ghla99pm85ksz  Error: ErrImagePull
  Normal   BackOff    7m52s (x7 over 9m58s)   kubelet, izwz96awf0ghla99pm85ksz  Back-off pulling image "hlqlinux/hlq-test/nginx-v2"
  Warning  Failed     4m50s (x20 over 9m58s)  kubelet, izwz96awf0ghla99pm85ksz  Error: ImagePullBackOff

pull access denied for hlqlinux/hlq-test/nginx-v2, repository does not exist or may require ‘docker login’(镜像问题或者需要登录镜像仓库)

三、初步判断是镜像问题,查看自己的镜像仓库,镜像格式有问题

删除pod


[root@iZwz9gwr0avfoncztr5y2jZ ~]# kubectl delete -f hostpath.yaml 
pod "test-nginx" deleted
[root@iZwz9gwr0avfoncztr5y2jZ ~]# kubectl get pod 
NAME                     READY   STATUS    RESTARTS   AGE
nginx-855696b796-mb6cv   1/1     Running   0          3d23h

正确写入镜像后依然报错

[root@iZwz9gwr0avfoncztr5y2jZ ~]# kubectl get pod 
NAME                     READY   STATUS             RESTARTS   AGE
nginx-855696b796-mb6cv   1/1     Running            0          4d
test-nginx               0/1     CrashLoopBackOff   5          5m3s

Events:
  Type     Reason     Age                  From                              Message
  ----     ------     ----                 ----                              -------
  Normal   Scheduled  3m53s                default-scheduler                 Successfully assigned my-namespace/test-nginx to izwz96awf0ghla99pm85ksz
  Normal   Pulling    3m52s                kubelet, izwz96awf0ghla99pm85ksz  Pulling image "hlqlinux/hlq-test:nginx-v2"
  Normal   Pulled     2m20s                kubelet, izwz96awf0ghla99pm85ksz  Successfully pulled image "hlqlinux/hlq-test:nginx-v2"
  Normal   Created    42s (x5 over 2m19s)  kubelet, izwz96awf0ghla99pm85ksz  Created container test-nginx
  Normal   Started    42s (x5 over 2m19s)  kubelet, izwz96awf0ghla99pm85ksz  Started container test-nginx
  Normal   Pulled     42s (x4 over 2m18s)  kubelet, izwz96awf0ghla99pm85ksz  Container image "hlqlinux/hlq-test:nginx-v2" already present on machine
  Warning  BackOff    41s (x9 over 2m17s)  kubelet, izwz96awf0ghla99pm85ksz  Back-off restarting failed container

镜像有问题
在这里插入图片描述

四、更换成v3镜像

apiVersion: v1
kind: Pod
metadata:
  name: test-nginx
spec:
  containers:
  - image: hlqlinux/hlq-test:nginx-v3
    name: test-nginx
    volumeMounts:
    - mountPath: /test-pd
      name: test-volume
  volumes:
  - name: test-volume
    hostPath:
      # directory location on host
      path: /data

pod创建成功

[root@iZwz9gwr0avfoncztr5y2jZ ~]# kubectl get pod 
NAME                     READY   STATUS    RESTARTS   AGE
nginx-855696b796-mb6cv   1/1     Running   0          4d
test-nginx               1/1     Running   0          3s
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值