MacOS 安装 minikube 后执行 "minikube start" 卡在 "Booting up control plane ..."
提示
最终成功安装,版本选择一个稍微早些的就行。
minikube start \
--image-mirror-country='cn' \
--image-repository='registry.cn-hangzhou.aliyuncs.com/google_containers' \
--kubernetes-version=v1.23.1 # 重点是这里的版本号
踩坑记录
尝试了多种方法:
- brew 安装
- 源码安装
- 设置 driver 为 docker:
minikube config set driver docker
- 启动时指定
image-mirror-country
:minikube start --image-mirror-country='cn'
- 预先手动拉取镜像:
docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/storage-provisioner:v5
- ...
结果都失败了:
> minikube start --image-mirror-country='cn'
😄 Darwin 13.2.1 上的 minikube v1.29.0
✨ 根据用户配置使用 docker 驱动程序
✅ 正在使用镜像存储库 registry.cn-hangzhou.aliyuncs.com/google_containers
📌 Using Docker Desktop driver with root privileges
👍 Starting control plane node minikube in cluster minikube
🚜 Pulling base image ...
❗ minikube was unable to download registry.cn-hangzhou.aliyuncs.com/google_containers/kicbase:v0.0.37, but successfully downloaded docker.io/kicbase/stable:v0.0.37 as a fallback image
🔥 Creating docker container (CPUs=2, Memory=3885MB) ...
> kubectl.sha256: 64 B / 64 B [-------------------------] 100.00% ? p/s 0s
> kubelet.sha256: 64 B / 64 B [-------------------------] 100.00% ? p/s 0s
> kubeadm.sha256: 64 B / 64 B [-------------------------] 100.00% ? p/s 0s
> kubeadm: 41.77 MiB / 41.77 MiB [------------] 100.00% 15.88 MiB p/s 2.8s
> kubectl: 42.93 MiB / 42.93 MiB [------------] 100.00% 10.61 MiB p/s 4.2s
> kubelet: 108.94 MiB / 108.94 MiB [----------] 100.00% 14.76 MiB p/s 7.6s
▪ Generating certificates and keys ...
▪ Booting up control plane .../
都是卡在 Booting up control plane .../
或者卡了好久之后报一堆错;
尝试了好多方法后发现有一篇文章里提到指定 --kubernetes-version=某个版本
成功解决了。
开始尝试
查看 kubernetes 发行版本: https://kubernetes.io/zh-cn/releases/
之前的安装过程中发现默认使用的是最新版 1.26.1
, 然后尝试了 1.25.1
、1.24.1
、1.23.1
,发现只有 1.23.1
非常顺利的成功了。
[注意] 每次切换版本前先删除当前版本: minikube delete
> time minikube start \
--image-mirror-country='cn' \
--image-repository='registry.cn-hangzhou.aliyuncs.com/google_containers' \
--kubernetes-version=v1.23.1
😄 Darwin 13.2.1 上的 minikube v1.29.0
✨ 根据用户配置使用 docker 驱动程序
✅ 正在使用镜像存储库 registry.cn-hangzhou.aliyuncs.com/google_containers
📌 Using Docker Desktop driver with root privileges
👍 Starting control plane node minikube in cluster minikube
🚜 Pulling base image ...
❗ minikube was unable to download registry.cn-hangzhou.aliyuncs.com/google_containers/kicbase:v0.0.37, but successfully downloaded docker.io/kicbase/stable:v0.0.37 as a fallback image
🔥 Creating docker container (CPUs=2, Memory=3885MB) ...
🐳 正在 Docker 20.10.23 中准备 Kubernetes v1.23.1…
▪ Generating certificates and keys ...
▪ Booting up control plane ...
▪ Configuring RBAC rules ...
▪ Using image registry.cn-hangzhou.aliyuncs.com/google_containers/storage-provisioner:v5
🔎 Verifying Kubernetes components...
🌟 Enabled addons: storage-provisioner, default-storageclass
❗ /usr/local/bin/kubectl is version 1.25.4, which may have incompatibilities with Kubernetes 1.23.1.
▪ Want kubectl v1.23.1? Try 'minikube kubectl -- get pods -A'
🏄 Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default
39.64 real 5.17 user 3.11 sys
完整记录
1. 安装 minikube
按照官方文档安装即可: minikube start
To install the latest minikube stable
release on x86-64
macOS
using binary download
:
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-darwin-amd64
sudo install minikube-darwin-amd64 /usr/local/bin/minikube
通过
brew
安装的我没有再尝试,盲猜应该也可以了 😏,毕竟问题在于kubernetes
的版本。
2. minikube start 关键来了
主要就是这个版本号, 没问题的话分分钟就启动成功了。
这篇文章的时间是 2023-02-18
,实际情况可以参考 kubernetes
的最新版本信息。
minikube start \
--image-mirror-country='cn' \
--image-repository='registry.cn-hangzhou.aliyuncs.com/google_containers' \
--kubernetes-version=v1.23.1
3. 验证安装
命令行验证
❯ minikube kubectl -- get po -A
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system coredns-65c54cc984-5bd6m 1/1 Running 0 73m
kube-system etcd-minikube 1/1 Running 0 73m
kube-system kube-apiserver-minikube 1/1 Running 0 73m
kube-system kube-controller-manager-minikube 1/1 Running 0 73m
kube-system kube-proxy-zhf7h 1/1 Running 0 73m
kube-system kube-scheduler-minikube 1/1 Running 0 73m
kube-system storage-provisioner 1/1 Running 1 (73m ago) 73m
注意因为本机
kubectl
和这里选择的kubernetes
版本不一定兼容,这里用的是minikube kubectl -- get po -A
而不是kubectl get po -A
为便于直接使用 kubectl
命令可以进行以下设置:
# 关于这个在官网有说明: https://minikube.sigs.k8s.io/docs/start/
alias kubectl="minikube kubectl --"
使用 minikube dashboard
:
❯ minikube dashboard
🔌 正在开启 dashboard ...
▪ Using image docker.io/kubernetesui/metrics-scraper:v1.0.8
▪ Using image docker.io/kubernetesui/dashboard:v2.7.0
💡 Some dashboard features require the metrics-server addon. To enable all features please run:
minikube addons enable metrics-server
🤔 正在验证 dashboard 运行情况 ...
🚀 Launching proxy ...
🤔 正在验证 proxy 运行状况 ...
🎉 Opening http://127.0.0.1:52528/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/ in your default browser...
顺利的话浏览器已经自动打开 dashboard
页面了:
记录下来这个过程,希望对有类似问题的小伙伴有用 😄