minikube所需的鏡像在拉取時,要求網絡能夠訪問k8s.gcr.io
。而此地址屬於著名的404公司,在國內是無法訪問的。
新版本的minikube已經在命令行中,充分考慮到了國內用戶的網絡情況,並提供了相應的命令行參數。不過網上大多博客的說明沒有更新,在處理鏡像拉取時,會讓初學者浪費大量的時間處理網絡問題。
具體說明可以通過minikube start --help
命令查看,節選如下:
--image-mirror-country='': Country code of the image mirror to be used. Leave empty to use the global one. For
Chinese mainland users, set it to cn.
--image-repository='': Alternative image repository to pull docker images from. This can be used when you have
limited access to gcr.io. Set it to "auto" to let minikube decide one for you. For Chinese mainland users, you may use
local gcr.io mirrors such as registry.cn-hangzhou.aliyuncs.com/google_containers
上面的幫助說明中,已經把國內用戶需要填什么都說清楚了,可以說很良心了。在國內不借助代理的情況下,minikube正確的打開方式應該是:
Linux環境:
minikube start --driver='docker' --image-mirror-country='cn' --image-repository='registry.cn-hangzhou.aliyuncs.com/google_containers'
#or bare metal
sudo minikube start --driver='none' --image-mirror-country='cn' --image-repository='registry.cn-hangzhou.aliyuncs.com/google_containers'
Windows環境:
minikube start --image-mirror-country="cn"