minikube apiserver无法启动问题解决
1 问题描述
按照minikube官方文档的描述,安装完成minikube之后,直接使用minikube start即可启动一个集群。然后,我却经历了无数周折还是不行。今天又花一天时间来研究这个问题。
2 问题解决
搜索网络相关文档,通过如下命令可以输出详细日志 :
minikube start --alsologtostderr -v=8
可以大体看到是向apiserver无法注册的问题。最后了解到了可以使用minikube status查看状态,总是显示:
apiserver: Stopped
所以,问题的根源是apiserver无法启动。
在网络上反覆查找资料,尝试在minikube start后添加–vm-driver 、–driver、–kubernetes-version等参数配置,均已失败告终。好在黄天不负苦心人,看到这篇文件https://www.zhaowenyu.com/minikube-doc/handbook/config.html,尝试了添加–container-runtime参数:
minikube start --container-runtime=containerd
终于成功了:
😄 Ubuntu 22.04 上的 minikube v1.29.0
✨ 根据用户配置使用 docker 驱动程序
📌 Using Docker driver with root privileges
👍 Starting control plane node minikube in cluster minikube
🚜 Pulling base image ...
💾 Downloading Kubernetes v1.26.1 preload ...
> preloaded-images-k8s-v18-v1...: 427.51 MiB / 427.51 MiB 100.00% 2.28 Mi
🔥 Creating docker container (CPUs=2, Memory=2200MB) ...
🧯 Docker is nearly out of disk space, which may cause deployments to fail! (90% of capacity). You can pass '--force' to skip this check.
💡 建议:
Try one or more of the following to free up space on the device:
1. Run "docker system prune" to remove unused Docker data (optionally with "-a")
2. Increase the storage allocated to Docker for Desktop by clicking on:
Docker icon > Preferences > Resources > Disk Image Size
3. Run "minikube ssh -- docker system prune" if using the Docker container runtime
🍿 Related issue: https://github.com/kubernetes/minikube/issues/9024
🌐 找到的网络选项:
▪ HTTP_PROXY=http://0.0.0.0:20231/
❗ You appear to be using a proxy, but your NO_PROXY environment does not include the minikube IP (192.168.49.2).
📘 Please see https://minikube.sigs.k8s.io/docs/handbook/vpn_and_proxy/ for more details
▪ HTTPS_PROXY=http://0.0.0.0:20231/
▪ NO_PROXY=localhost,127.0.0.0/8,::1
▪ http_proxy=http://0.0.0.0:20231/
▪ https_proxy=http://0.0.0.0:20231/
▪ no_proxy=localhost,127.0.0.0/8,::1
❗ This container is having trouble accessing https://registry.k8s.io
💡 To pull new external images, you may need to configure a proxy: https://minikube.sigs.k8s.io/docs/reference/networking/proxy/
📦 正在 containerd 1.6.15 中准备 Kubernetes v1.26.1…
▪ env HTTP_PROXY=http://0.0.0.0:20231/
▪ env HTTPS_PROXY=http://0.0.0.0:20231/
▪ env NO_PROXY=localhost,127.0.0.0/8,::1
▪ Generating certificates and keys ...
▪ Booting up control plane ...
▪ Configuring RBAC rules ...
🔗 Configuring CNI (Container Networking Interface) ...
▪ Using image gcr.io/k8s-minikube/storage-provisioner:v5
🌟 Enabled addons: storage-provisioner, default-storageclass
🔎 Verifying Kubernetes components...
🏄 Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default
3 问题总结
最后总结一下,官方的文档总是太过于理想化,而现实中的软件运行环境总是多样的,导致很多意想不到的问题。就此次问题来说,我在本地环境中,已经配置容器环境默认使用containerd,而不是docker,或许这才是导致此次问题的原因。