一、环境
Windows 10
C:\Users\zhuji>docker --version
Docker version 24.0.2, build cb74dfc
二、问题
在setting -> Kubernetes 中,选中 Enable Kubernetes 后,长时间显示 Starting ... ,在Images中显示几个自动下载的镜像后,显示 Start Kubernetes failed.
查找资料发现,启用Kubernetes后,docker需要从国外源仓库下载一批镜像以便启用Kubernetes,这现国外的仓库访问速度较慢无法正常下载所需镜像,导致集群启用失败。根据这些资料所说,方法有二种,一种使用国内源,一种使用VPN。
三、使用国内源
在Setting -> Docker Engine config中输入国内源地址
"registry-mirrors": [
"http://hub-mirror.c.163.com",
"https://docker.mirrors.ustc.edu.cn",
"https://cr.console.aliyun.com/"
]
然后无论重置Kubernetes ,重启Docker Desktop, 重启机器,均不能成功启动,Docker还会去国外源拉取镜像,此路不通。
四、外挂VPN
启用VPN后,可以从国外源拉取到镜像文件,下载速度较慢,等一段时间后,可以看到docker 下载了10个镜像文件。
C:\Users\zhuji>docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hubproxy.docker.internal:5555/docker/desktop-kubernetes kubernetes-v1.27.2-cni-v1.2.0-critools-v1.27.0-cri-dockerd-v0.3.2-1-debian c763812a4530 2 months ago 418MB
registry.k8s.io/kube-apiserver v1.27.2 c5b13e4f7806 2 months ago 121MB
registry.k8s.io/kube-scheduler v1.27.2 89e70da428d2 2 months ago 58.4MB
registry.k8s.io/kube-controller-manager v1.27.2 ac2b7465ebba 2 months ago 112MB
registry.k8s.io/kube-proxy v1.27.2 b8aa50768fd6 2 months ago 71.1MB
docker/desktop-vpnkit-controller dc331cb22850be0cdd97c84a9cfecaf44a1afb6e 556098075b3d 2 months ago 36.2MB
registry.k8s.io/coredns/coredns v1.10.1 ead0a4a53df8 6 months ago 53.6MB
registry.k8s.io/etcd 3.5.7-0 86b6af7dd652 6 months ago 296MB
registry.k8s.io/pause 3.9 e6f181688397 9 months ago 744kB
docker/desktop-storage-provisioner v2.0 99f89471f470 2 years ago 41.9MB
然后Kubernetes就启动成功了。
文章来源:https://www.toymoban.com/news/detail-635887.html
文章来源地址https://www.toymoban.com/news/detail-635887.html
五、验证
C:\Users\zhuji>kubectl version
WARNING: This version information is deprecated and will be replaced with the output from kubectl version --short. Use --output=yaml|json to get the full version.
Client Version: version.Info{Major:"1", Minor:"27", GitVersion:"v1.27.2", GitCommit:"7f6f68fdabc4df88cfea2dcf9a19b2b830f1e647", GitTreeState:"clean", BuildDate:"2023-05-17T14:20:07Z", GoVersion:"go1.20.4", Compiler:"gc", Platform:"windows/amd64"}
Kustomize Version: v5.0.1
Server Version: version.Info{Major:"1", Minor:"27", GitVersion:"v1.27.2", GitCommit:"7f6f68fdabc4df88cfea2dcf9a19b2b830f1e647", GitTreeState:"clean", BuildDate:"2023-05-17T14:13:28Z", GoVersion:"go1.20.4", Compiler:"gc", Platform:"linux/amd64"}
C:\Users\zhuji>kubectl get namespaces
NAME STATUS AGE
default Active 11d
kube-node-lease Active 11d
kube-public Active 11d
kube-system Active 11d
C:\Users\zhuji>kubectl get pods -n kube-system
NAME READY STATUS RESTARTS AGE
coredns-5d78c9869d-rvrw4 1/1 Running 8 (18m ago) 11d
coredns-5d78c9869d-vmnmd 1/1 Running 8 (18m ago) 11d
etcd-docker-desktop 1/1 Running 8 (18m ago) 11d
kube-apiserver-docker-desktop 1/1 Running 8 (18m ago) 11d
kube-controller-manager-docker-desktop 1/1 Running 8 (18m ago) 11d
kube-proxy-7jf5m 1/1 Running 8 (18m ago) 11d
kube-scheduler-docker-desktop 1/1 Running 8 (18m ago) 11d
storage-provisioner 1/1 Running 16 (18m ago) 11d
vpnkit-controller 1/1 Running 8 (18m ago) 11d
到了这里,关于Docker Desktop 启用 Kubernetes 失败后处理的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!