栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

创建Pod时k8s镜像拉取失败

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

创建Pod时k8s镜像拉取失败

创建POD时k8s镜像拉取失败
    • 一、使用yaml文件创建一个pod,发现pod无法起来,报错:ImagePullBackOff
    • 二、查询创建状态
    • 三、初步判断是镜像问题,查看自己的镜像仓库,镜像格式有问题
    • 四、更换成v3镜像

一、使用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:       
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:           
    Host Port:      
    State:          Waiting
      Reason:       ImagePullBackOff
    Ready:          False
    Restart Count:  0
    Environment:    
    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:  
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
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/644538.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号