*使用minikube搭建k8s,遇到的最大的问题就是拉取不到镜像。用阿里云提供的minikube可以完美解决
详情见如下文章,minikube地址见如下文章
https://github.com/AliyunContainerService/minikube
https://developer.aliyun.com/article/221687
通过如下命令下载minikube
#Mac OSX
curl -Lo minikube https://kubernetes.oss-cn-hangzhou.aliyuncs.com/minikube/releases/v1.17.1/minikube-darwin-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
#linux
curl -Lo minikube https://kubernetes.oss-cn-hangzhou.aliyuncs.com/minikube/releases/v1.17.1/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
下载好后,不能直接用root账号运行minikube,不然会报如下错误:
“The "docker" driver should not be used with root privileges.”
我们需要创建一个普通用户,不用赋sudo权限,需要加入到docker用户组中即可。
useradd $user
usermod -aG $user docker
创建好用户后,用该用户运行minikube start 会拉取到必要的镜像,除了kicbase ,然后会报如下错误:
Unable to find image 'gcr.io/k8s-minikube/kicbase:v0.0.18@sha256:ddd0c02d289e3a6fb4bba9a94435840666f4eb81484ff3e707b69c1c484aa45e' locally
docker: Error response from daemon: Get https://gcr.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers).
解决办法,通过anjone/kicbase镜像包来代替 gcr.io/k8s-minikube/kicbase:v0.0.18
如果docker拉取不到该镜像,记得配置国内镜像源registry.cn-hangzhou.aliyuncs.com/google_containers,最后在minikube运行命令中指定这个镜像
docker pull anjone/kicbase
minikube start --base-image="anjone/kicbase"
最后结果: