代码之家  ›  专栏  ›  技术社区  ›  Hantsy

种类(K8S)拉动imgaes失败

  •  1
  • Hantsy  · 技术社区  · 5 年前

    我试着用 KinD 作为Minikube的替代方案,在本地机器中引导K8S群集。

    群集已成功创建。

    但当我尝试从映像创建一些pod/部署时,失败了。

    $ kubectl run nginx --image=nginx
    $ kubectl run hello --image=hello-world
    

    几分钟后,使用 get pods 获取失败状态。

    $ kubectl get pods
    NAME    READY   STATUS             RESTARTS   AGE
    hello   0/1     ImagePullBackOff   0          11m
    nginx   0/1     ImagePullBackOff   0          22m
    

    恐怕这是中国的另一个全球防火墙问题。

    kubectl describe pods/nginx
    Name:         nginx
    Namespace:    default
    Priority:     0
    Node:         dev-control-plane/172.19.0.2
    Start Time:   Sun, 30 Aug 2020 19:46:06 +0800
    Labels:       run=nginx
    Annotations:  <none>
    Status:       Pending
    IP:           10.244.0.5
    IPs:
      IP:  10.244.0.5
    Containers:
      nginx:
        Container ID:
        Image:          nginx
        Image ID:
        Port:           <none>
        Host Port:      <none>
        State:          Waiting
          Reason:       ErrImagePull
        Ready:          False
        Restart Count:  0
        Environment:    <none>
        Mounts:
          /var/run/secrets/kubernetes.io/serviceaccount from default-token-mgq96 (ro)
    Conditions:
      Type              Status
      Initialized       True
      Ready             False
      ContainersReady   False
      PodScheduled      True
    Volumes:
      default-token-mgq96:
        Type:        Secret (a volume populated by a Secret)
        SecretName:  default-token-mgq96
        Optional:    false
    QoS Class:       BestEffort
    Node-Selectors:  <none>
    Tolerations:     node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                     node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
    Events:
      Type     Reason     Age                From                        Message
      ----     ------     ----               ----                        -------
      Normal   Scheduled  56m                default-scheduler           Successfully assigned default/nginx to dev-control-plane
      Normal   BackOff    40m                kubelet, dev-control-plane  Back-off pulling image "nginx"
      Warning  Failed     40m                kubelet, dev-control-plane  Error: ImagePullBackOff
      Warning  Failed     13m (x3 over 40m)  kubelet, dev-control-plane  Failed to pull image "nginx": rpc error: code = Unknown desc = failed to pull and unpack image "docker.io/library/nginx:latest": failed to copy: unexpected EOF
      Warning  Failed     13m (x3 over 40m)  kubelet, dev-control-plane  Error: ErrImagePull
      Normal   Pulling    13m (x4 over 56m)  kubelet, dev-control-plane  Pulling image "nginx"
    

    当我进入最仁慈的/节点容器时,但其中没有docker。 不知道这是怎么回事 ,最初我理解它将K8S集群部署到Docker容器中。

    $ docker ps
    CONTAINER ID        IMAGE                  COMMAND                  CREATED             STATUS              PORTS                       NAMES
    a644f8b61314        kindest/node:v1.19.0   "/usr/local/bin/entr…"   About an hour ago   Up About an hour    127.0.0.1:52301->6443/tcp   dev-control-plane
    
    $ docker exec -it  a644f8b61314  /bin/bash
    root@dev-control-plane:/# docker -v
    bash: docker: command not found
    

    在阅读了Kind文档之后,我找不到像Minikube那样在那里设置存储库镜像的选项。

    顺便说一句,我正在Windows10上使用最新的Docker桌面测试版。

    0 回复  |  直到 5 年前
        1
  •  4
  •   Arghya Sadhu Dharmesh    5 年前

    首先在本地系统中使用 docker pull nginx 然后使用下面的命令将该图像加载到种类集群

    kind load docker-image nginx --name kind-cluster-name 
    

    善用 containerd 这就是为什么docker没有安装在节点上,而不是作为运行时。

    或者,您可以使用 crictl 用于拉取和检查“种类”节点内的图像的工具。

    crictl pull nginx
    crictl images
    
    推荐文章