欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Unable to pull images, failed to pull image k8s.gcr.io 解决办法

程序员文章站 2022-07-13 22:20:28
...

好多人在初试kubernetes的时候就出现这个问题,然后尝试各种办法之后还是不能解决,最后就不了了之了。

Pulling images required by Kubernetes v1.13.3 ...
❌  Unable to pull images, which may be OK: running cmd: sudo kubeadm config images pull --config /var/lib/kubeadm.yaml: command failed: sudo kubeadm config images pull --config /var/lib/kubeadm.yaml
stdout: 
stderr: failed to pull image "k8s.gcr.io/kube-apiserver:v1.13.3": output: Error response from daemon: Get https://k8s.gcr.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
, error: exit status 1
: Process exited with status 1
????  Launching Kubernetes v1.13.3 using kubeadm ... 
????  Error starting cluster: kubeadm init: 
sudo /usr/bin/kubeadm init --config /var/lib/kubeadm.yaml --ignore-preflight-errors=DirAvailable--etc-kubernetes-manifests --ignore-preflight-errors=DirAvailable--data-minikube --ignore-preflight-errors=Port-10250 --ignore-preflight-errors=FileAvailable--etc-kubernetes-manifests-kube-scheduler.yaml --ignore-preflight-errors=FileAvailable--etc-kubernetes-manifests-kube-apiserver.yaml --ignore-preflight-errors=FileAvailable--etc-kubernetes-manifests-kube-controller-manager.yaml --ignore-preflight-errors=FileAvailable--etc-kubernetes-manifests-etcd.yaml --ignore-preflight-errors=Swap --ignore-preflight-errors=CRI 

[init] Using Kubernetes version: v1.13.3
[preflight] Running pre-flight checks
    [WARNING Service-Docker]: docker service is not enabled, please run 'systemctl enable docker.service'
    [WARNING Swap]: running with swap on is not supported. Please disable swap
[preflight] Pulling images required for setting up a Kubernetes cluster
[preflight] This might take a minute or two, depending on the speed of your internet connection
[preflight] You can also perform this action in beforehand using 'kubeadm config images pull'
error execution phase preflight: [preflight] Some fatal errors occurred:
    [ERROR ImagePull]: failed to pull image k8s.gcr.io/kube-apiserver:v1.13.3: output: Error response from daemon: Get https://k8s.gcr.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
, error: exit status 1
    [ERROR ImagePull]: failed to pull image k8s.gcr.io/kube-controller-manager:v1.13.3: output: Error response from daemon: Get https://k8s.gcr.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
, error: exit status 1
    [ERROR ImagePull]: failed to pull image k8s.gcr.io/kube-scheduler:v1.13.3: output: Error response from daemon: Get https://k8s.gcr.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
....
[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`

: Process exited with status 1

虽然我有*,但是我也差点放弃了,因为即使有*,按照网络上各大教程,还是会出现这个问题。

我尝试过将minikube需要的镜像下载到远程服务器,然后上传到docker的hub中,然后再在minikube中下载,更改tag名称,好像成功了一次,然后我再 minikube start 之后,又出现了如上的问题。(很大一部分文章都是这样的)

也查到过官方的代理设置文档(minikube 代理 ),按照设置还是不能解决问题。但是在尝试的过程中发现还是这个比较靠谱。休息了一个晚上,第二天差点要放弃的时候,无意中发现了一个ip地址10.0.2.2 ,然后就尝试如下命令启动,既然成功了。当然,还是需要自备*。

--docker-env HTTP_PROXY=http://10.0.2.2:1087 --docker-env HTTPS_PROXY=http://10.0.2.2:1087

ps:*上也有个国人出现过这个问题,答案是我回答的。

然后我又继续加了一个alisa命令:

alias kubestart="minikube start --docker-env HTTP_PROXY=http://10.0.2.2:1087 --docker-env HTTPS_PROXY=http://10.0.2.2:1087"

下次再想要启动minikube的时候,直接输入kubestart这个命令即可了。

转载于:https://my.oschina.net/csq/blog/3014879