minikube 安装遇到的坑

minikube是个可以在自己电脑上体验kubernetes功能的软件包,怎么安装可参考 https://minikube.sigs.k8s.io/docs/start/ 来进行安装,下面说下在安装过程中遇到的坑。
因为我比较倾向于使用docker,所以minikube 驱动默认就是用docker
1、运行minikube start 结果出现下面这些错误,后来

 minikube v1.10.1 on Darwin 10.14.4
✨  Using the docker driver based on existing profile
  Starting control plane node minikube in cluster minikube
  Pulling base image ...
E0517 14:23:52.588016   27398 cache.go:129] Error downloading kic artifacts:  getting remote image: GET https://docker.pkg.github.com/v2/kubernetes/minikube/kicbase/manifests/v0.0.10: UNAUTHORIZED: GitHub Docker Registry needs login
  docker "minikube" container is missing, will recreate.
E0517 14:23:53.966331   27398 oci.go:79] docker daemon seems to be stuck. Please try restarting your docker. Will try to delete anyways: unknown state "minikube": docker inspect minikube --format={{.State.Status}}: exit status 1
stdout:


stderr:
Template parsing error: template: :1:8: executing "" at <.State.Status>: map has no entry for key "State"
  Creating docker container (CPUs=2, Memory=2200MB) ...
  StartHost failed, but will try again: recreate: creating host: create: creating: create kic node: create container: docker run -d -t --privileged --security-opt seccomp=unconfined --security-opt apparmor=unconfined --tmpfs /tmp --tmpfs /run -v /lib/modules:/lib/modules:ro --hostname minikube --name minikube --label created_by.minikube.sigs.k8s.io=true --label name.minikube.sigs.k8s.io=minikube --label role.minikube.sigs.k8s.io= --label mode.minikube.sigs.k8s.io=minikube --volume minikube:/var --cpus=2 --memory=2200mb -e container=docker --expose 8443 --publish=127.0.0.1::8443 --publish=127.0.0.1::22 --publish=127.0.0.1::2376 --publish=127.0.0.1::5000 docker.pkg.github.com/kubernetes/minikube/kicbase:v0.0.10: exit status 125
stdout:

stderr:
Unable to find image 'docker.pkg.github.com/kubernetes/minikube/kicbase:v0.0.10' locally
docker: Error response from daemon: Get https://docker.pkg.github.com/v2/kubernetes/minikube/kicbase/manifests/v0.0.10: no basic auth credentials.
See 'docker run --help'.

  docker "minikube" container is missing, will recreate.
E0517 14:24:45.275003   27398 oci.go:79] docker daemon seems to be stuck. Please try restarting your docker. Will try to delete anyways: unknown state "minikube": docker inspect minikube --format={{.State.Status}}: exit status 1
stdout:


stderr:
Template parsing error: template: :1:8: executing "" at <.State.Status>: map has no entry for key "State"
  Creating docker container (CPUs=2, Memory=2200MB) ...
  Failed to start docker container. "minikube start" may fix it: recreate: creating host: create: creating: create kic node: create container: docker run -d -t --privileged --security-opt seccomp=unconfined --security-opt apparmor=unconfined --tmpfs /tmp --tmpfs /run -v /lib/modules:/lib/modules:ro --hostname minikube --name minikube --label created_by.minikube.sigs.k8s.io=true --label name.minikube.sigs.k8s.io=minikube --label role.minikube.sigs.k8s.io= --label mode.minikube.sigs.k8s.io=minikube --volume minikube:/var --cpus=2 --memory=2200mb -e container=docker --expose 8443 --publish=127.0.0.1::8443 --publish=127.0.0.1::22 --publish=127.0.0.1::2376 --publish=127.0.0.1::5000 docker.pkg.github.com/kubernetes/minikube/kicbase:v0.0.10: exit status 125
stdout:

stderr:
Unable to find image 'docker.pkg.github.com/kubernetes/minikube/kicbase:v0.0.10' locally
docker: Error response from daemon: Get https://docker.pkg.github.com/v2/kubernetes/minikube/kicbase/manifests/v0.0.10: no basic auth credentials.
See 'docker run --help'.


  error provisioning host: Failed to start host: recreate: creating host: create: creating: create kic node: create container: docker run -d -t --privileged --security-opt seccomp=unconfined --security-opt apparmor=unconfined --tmpfs /tmp --tmpfs /run -v /lib/modules:/lib/modules:ro --hostname minikube --name minikube --label created_by.minikube.sigs.k8s.io=true --label name.minikube.sigs.k8s.io=minikube --label role.minikube.sigs.k8s.io= --label mode.minikube.sigs.k8s.io=minikube --volume minikube:/var --cpus=2 --memory=2200mb -e container=docker --expose 8443 --publish=127.0.0.1::8443 --publish=127.0.0.1::22 --publish=127.0.0.1::2376 --publish=127.0.0.1::5000 docker.pkg.github.com/kubernetes/minikube/kicbase:v0.0.10: exit status 125
stdout:

stderr:
Unable to find image 'docker.pkg.github.com/kubernetes/minikube/kicbase:v0.0.10' locally
docker: Error response from daemon: Get https://docker.pkg.github.com/v2/kubernetes/minikube/kicbase/manifests/v0.0.10: no basic auth credentials.
See 'docker run --help'.


  minikube is exiting due to an error. If the above message is not useful, open an issue:
  https://github.com/kubernetes/minikube/issues/new/choose

后来查了很多资料,但都没找到问题,但因为看到都是docker没法下载镜像,所以就怀疑是不是安装源不对,但是我是用的是网上大家都推荐的https://registry.docker-cn.com 这个说是docker中国的安装源,但我试了下确实没法访问,所以怀疑这个已经不可用了,于是就把地址改成阿里云的镜像源地址,因为是试验还不确定,就临时网上找了个阿里云的镜像地址https://f1z25q5p.mirror.aliyuncs.com, 发现这下镜像可以正常拉取了。

二,单独拉去某个镜像 minikube 在pull anjone/kicbase这个镜像时候总是报错,在网上找了下,说是地址无法访问,可以先在docker上面把anjone/kicbase镜像拉去下来,然后再通过命令minikube start --vm-driver=docker --base-image="anjone/kicbase" 单独指定使用镜像就可以了,经过这样操作,终于minikube运行起来了
minikube status

minikube
type: Control Plane
host: Running
kubelet: Running
apiserver: Running
kubeconfig: Configured

虽然minikube可以运行起来了,但是当搭建多个nginx 节点时候,却显示
ImagePullBackOff

kubectl get pod
NAME                                READY   STATUS             RESTARTS   AGE
hello-minikube-64b667545-dlkcp      0/1     ImagePullBackOff   0          157m
nginx-deployment-6b474476c4-7nxdm   0/1     ImagePullBackOff   0          148m
nginx-deployment-6b474476c4-k6594   0/1     ImagePullBackOff   0          148m

再通过查看pod信息

kubectl describe pod nginx-deployment-6b474476c4-7nxdm

 Warning  Failed     146m                  kubelet, minikube  Failed to pull image "nginx:1.14.2": rpc error: code = Unknown desc = Get https://registry-1.docker.io/v2/library/nginx/manifests/sha256:706446e9c6667c0880d5da3f39c09a6c7d2114f5a5d6b74a2fafd24ae30d2078: net/http: TLS handshake timeout
  Normal   Pulling    144m (x4 over 148m)   kubelet, minikube  Pulling image "nginx:1.14.2"
  Warning  Failed     144m (x2 over 145m)   kubelet, minikube  Failed to pull image "nginx:1.14.2": rpc error: code = Unknown desc = Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: TLS handshake timeout
  Normal   BackOff    138m (x25 over 148m)  kubelet, minikube  Back-off pulling image "nginx:1.14.2"
  Warning  Failed     132m (x7 over 148m)   kubelet, minikube  Error: ErrImagePull
  Warning  Failed     123m (x84 over 148m)  kubelet, minikube  Error: ImagePullBackOff
  Warning  Failed     105m                  kubelet, minikube  Failed to pull image "nginx:1.14.2": rpc error: code = Unknown desc = Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)

显示的是拉去镜像失败,经过分析应该是minikube使用的镜像源是国外的,所以无法拉去成功,后来经过各种实验,发现minikube有参数可以设置源地址,把之前建立的minikube配置 通过 minikube delete 后,重新设置

minikube start --vm-driver=docker  --base-image="anjone/kicbase"   --registry-mirror=https://f1z25q5p.mirror.aliyuncs.com

通过

minikube dashboard

可以看到节点都已正常运行


图片.png

参考文章:
https://minikube.sigs.k8s.io/docs/start/
https://yq.aliyun.com/articles/221687?commentId=17521
https://edu.aliyun.com/lesson_1651_16894?spm=5176.10731542.0.0.471020bejI7ls8#_16894

你可能感兴趣的:(minikube 安装遇到的坑)