某种kubernetes集群无法提取docker映像

时间:2020-08-30 12:28:05

标签: docker kubernetes

我尝试使用KinD作为Minikube的替代方案,以在本地计算机上引导K8S集群。

集群创建成功。

但是当我尝试从图像创建一些吊舱/部署时,它失败了。

$ 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"

当我输入kindest / node容器时,其中没有docker。 不确定KIND的工作方式,最初我了解它是将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中设置存储库镜像的选项。

顺便说一句,我正在Windows 10上使用最新的Docker Desktop beta。

1 个答案:

答案 0 :(得分:2)

首先使用docker pull nginx在本地系统中提取图像,然后使用下面的命令将该图像加载到同类簇中

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

种类使用containerd而不是docker作为运行时,这就是为什么未在节点上安装docker的原因。

或者,您可以使用crictl工具在同类节点中提取并检查图像。

crictl pull nginx
crictl images